示例#1
0
// read the contents of an object as a string
func readObject(t *testing.T, obj fs.Object, options ...fs.OpenOption) string {
	in, err := obj.Open(options...)
	require.NoError(t, err)
	contents, err := ioutil.ReadAll(in)
	require.NoError(t, err)
	err = in.Close()
	require.NoError(t, err)
	return string(contents)
}
示例#2
0
func newReadFileHandle(o fs.Object) (*ReadFileHandle, error) {
	r, err := o.Open()
	if err != nil {
		return nil, err
	}
	return &ReadFileHandle{
		r: r,
		o: o,
	}, nil
}
示例#3
0
文件: read.go 项目: ncw/rclone
func newReadFileHandle(o fs.Object) (*ReadFileHandle, error) {
	r, err := o.Open()
	if err != nil {
		return nil, err
	}
	fh := &ReadFileHandle{
		o: o,
		r: fs.NewAccount(r, o), // account the transfer
	}
	fs.Stats.Transferring(fh.o.Remote())
	return fh, nil
}