Documentation ¶
Index ¶
- type BufferedReadHandle
- type BytesPool
- type CreateOptions
- type Filesystem
- type FilesystemLocal
- type FilesystemRemote
- type GenericMultiReadHandle
- func (o *GenericMultiReadHandle) Close() error
- func (o *GenericMultiReadHandle) Info(ctx context.Context) (*ObjectInfo, error)
- func (o *GenericMultiReadHandle) Length() int64
- func (o *GenericMultiReadHandle) NextPart(ctx context.Context, length int64) (ReadHandle, error)
- func (o *GenericMultiReadHandle) SetOffset(offset int64) error
- type GenericReader
- type ListOptions
- type Local
- func (l *Local) Copy(ctx context.Context, oldpath, newpath string) error
- func (l *Local) Create(ctx context.Context, path string) (WriteHandle, error)
- func (l *Local) IsLocalDir(ctx context.Context, path string) bool
- func (l *Local) List(ctx context.Context, path string, opts *ListOptions) (ObjectIterator, error)
- func (l *Local) Move(ctx context.Context, oldpath, newpath string) error
- func (l *Local) Open(ctx context.Context, path string) (MultiReadHandle, error)
- func (l *Local) Remove(ctx context.Context, path string, opts *RemoveOptions) error
- func (l *Local) Stat(ctx context.Context, path string) (*ObjectInfo, error)
- type LocalBackend
- type LocalBackendFile
- type LocalBackendMem
- func (l *LocalBackendMem) Create(name string) (LocalBackendFile, error)
- func (l *LocalBackendMem) MkdirAll(name string, perm os.FileMode) error
- func (l *LocalBackendMem) Open(name string) (LocalBackendFile, error)
- func (l *LocalBackendMem) Remove(name string) error
- func (l *LocalBackendMem) Rename(oldname, newname string) error
- func (l *LocalBackendMem) Stat(name string) (os.FileInfo, error)
- type LocalBackendOS
- func (l *LocalBackendOS) Create(name string) (LocalBackendFile, error)
- func (l *LocalBackendOS) MkdirAll(path string, perm os.FileMode) error
- func (l *LocalBackendOS) Open(name string) (LocalBackendFile, error)
- func (l *LocalBackendOS) Remove(name string) error
- func (l *LocalBackendOS) Rename(oldname, newname string) error
- func (l *LocalBackendOS) Stat(name string) (os.FileInfo, error)
- type Mixed
- func (m *Mixed) Close() error
- func (m *Mixed) Copy(ctx context.Context, source, dest ulloc.Location) error
- func (m *Mixed) Create(ctx context.Context, loc ulloc.Location, opts *CreateOptions) (WriteHandle, error)
- func (m *Mixed) IsLocalDir(ctx context.Context, loc ulloc.Location) bool
- func (m *Mixed) List(ctx context.Context, prefix ulloc.Location, opts *ListOptions) (ObjectIterator, error)
- func (m *Mixed) Move(ctx context.Context, source, dest ulloc.Location) error
- func (m *Mixed) Open(ctx context.Context, loc ulloc.Location) (MultiReadHandle, error)
- func (m *Mixed) Remove(ctx context.Context, loc ulloc.Location, opts *RemoveOptions) error
- func (m *Mixed) Stat(ctx context.Context, loc ulloc.Location) (*ObjectInfo, error)
- type MultiReadHandle
- type ObjectInfo
- type ObjectIterator
- type ReadHandle
- type Remote
- func (r *Remote) Close() error
- func (r *Remote) Copy(ctx context.Context, oldbucket, oldkey, newbucket, newkey string) error
- func (r *Remote) Create(ctx context.Context, bucket, key string, opts *CreateOptions) (WriteHandle, error)
- func (r *Remote) List(ctx context.Context, bucket, prefix string, opts *ListOptions) ObjectIterator
- func (r *Remote) Move(ctx context.Context, oldbucket, oldkey, newbucket, newkey string) error
- func (r *Remote) Open(ctx context.Context, bucket, key string) (MultiReadHandle, error)
- func (r *Remote) Remove(ctx context.Context, bucket, key string, opts *RemoveOptions) error
- func (r *Remote) Stat(ctx context.Context, bucket, key string) (*ObjectInfo, error)
- type RemoveOptions
- type WriteHandle
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferedReadHandle ¶ added in v1.57.1
type BufferedReadHandle struct {
// contains filtered or unexported fields
}
BufferedReadHandle wraps a ReadHandler with an in-memory buffer.
func (*BufferedReadHandle) Close ¶ added in v1.57.1
func (b *BufferedReadHandle) Close() error
Close closes the wrapped ReadHandle.
func (*BufferedReadHandle) Info ¶ added in v1.57.1
func (b *BufferedReadHandle) Info() ObjectInfo
Info returns Info of the wrapped ReadHandle.
type BytesPool ¶ added in v1.57.1
type BytesPool struct {
// contains filtered or unexported fields
}
BytesPool is a fixed-size pool of []byte.
func NewBytesPool ¶ added in v1.57.1
NewBytesPool creates a pool for []byte slices of length `size`.
type CreateOptions ¶ added in v1.51.1
CreateOptions contains extra options to create an object.
type Filesystem ¶
type Filesystem interface { Close() error Open(ctx context.Context, loc ulloc.Location) (MultiReadHandle, error) Create(ctx context.Context, loc ulloc.Location, opts *CreateOptions) (WriteHandle, error) Move(ctx context.Context, source, dest ulloc.Location) error Copy(ctx context.Context, source, dest ulloc.Location) error Remove(ctx context.Context, loc ulloc.Location, opts *RemoveOptions) error List(ctx context.Context, prefix ulloc.Location, opts *ListOptions) (ObjectIterator, error) IsLocalDir(ctx context.Context, loc ulloc.Location) bool Stat(ctx context.Context, loc ulloc.Location) (*ObjectInfo, error) }
Filesystem represents either the local filesystem or the data backed by a project.
type FilesystemLocal ¶ added in v1.55.1
type FilesystemLocal interface { IsLocalDir(ctx context.Context, path string) bool Open(ctx context.Context, path string) (MultiReadHandle, error) Create(ctx context.Context, path string) (WriteHandle, error) Move(ctx context.Context, oldpath string, newpath string) error Copy(ctx context.Context, oldpath string, newpath string) error Remove(ctx context.Context, path string, opts *RemoveOptions) error List(ctx context.Context, path string, opts *ListOptions) (ObjectIterator, error) Stat(ctx context.Context, path string) (*ObjectInfo, error) }
FilesystemLocal is the interface for a local filesystem.
type FilesystemRemote ¶ added in v1.55.1
type FilesystemRemote interface { Close() error Open(ctx context.Context, bucket, key string) (MultiReadHandle, error) Create(ctx context.Context, bucket, key string, opts *CreateOptions) (WriteHandle, error) Move(ctx context.Context, oldbucket, oldkey string, newbucket, newkey string) error Copy(ctx context.Context, oldbucket, oldkey string, newbucket, newkey string) error Remove(ctx context.Context, bucket, key string, opts *RemoveOptions) error List(ctx context.Context, bucket, key string, opts *ListOptions) ObjectIterator Stat(ctx context.Context, bucket, key string) (*ObjectInfo, error) }
FilesystemRemote is the interface for a remote filesystem.
type GenericMultiReadHandle ¶
type GenericMultiReadHandle struct {
// contains filtered or unexported fields
}
GenericMultiReadHandle can turn any GenericReader into a MultiReadHandle.
func NewGenericMultiReadHandle ¶
func NewGenericMultiReadHandle(r GenericReader, info ObjectInfo) *GenericMultiReadHandle
NewGenericMultiReadHandle implements MultiReadHandle for *os.Files.
func (*GenericMultiReadHandle) Close ¶
func (o *GenericMultiReadHandle) Close() error
Close closes the GenericMultiReadHandle.
func (*GenericMultiReadHandle) Info ¶
func (o *GenericMultiReadHandle) Info(ctx context.Context) (*ObjectInfo, error)
Info returns the object info.
func (*GenericMultiReadHandle) Length ¶ added in v1.56.1
func (o *GenericMultiReadHandle) Length() int64
Length returns the size of the object.
func (*GenericMultiReadHandle) NextPart ¶
func (o *GenericMultiReadHandle) NextPart(ctx context.Context, length int64) (ReadHandle, error)
NextPart returns a ReadHandle of length bytes at the current offset.
func (*GenericMultiReadHandle) SetOffset ¶
func (o *GenericMultiReadHandle) SetOffset(offset int64) error
SetOffset will set the offset for the next call to NextPart.
type GenericReader ¶
GenericReader is an interface that can be turned into a GenericMultiReadHandle.
type ListOptions ¶
ListOptions describes options to the List command.
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
Local implements something close to a filesystem but backed by the local disk.
func (*Local) Create ¶
Create makes any directories necessary to create a file at path and returns a WriteHandle.
func (*Local) IsLocalDir ¶
IsLocalDir returns true if the path is a directory.
func (*Local) List ¶
func (l *Local) List(ctx context.Context, path string, opts *ListOptions) (ObjectIterator, error)
List returns an ObjectIterator listing files and directories that have string prefix with the provided path.
type LocalBackend ¶ added in v1.55.1
type LocalBackend interface { Create(name string) (LocalBackendFile, error) MkdirAll(path string, perm os.FileMode) error Open(name string) (LocalBackendFile, error) Remove(name string) error Rename(oldname, newname string) error Stat(name string) (os.FileInfo, error) }
LocalBackend abstracts what the Local filesystem interacts with.
type LocalBackendFile ¶ added in v1.55.1
type LocalBackendFile interface { io.Closer io.Writer io.ReaderAt Name() string Stat() (os.FileInfo, error) Readdir(int) ([]os.FileInfo, error) }
LocalBackendFile represents a file in the filesystem.
type LocalBackendMem ¶ added in v1.55.1
type LocalBackendMem struct {
// contains filtered or unexported fields
}
LocalBackendMem implements LocalBackend with memory backed files.
func NewLocalBackendMem ¶ added in v1.55.1
func NewLocalBackendMem() *LocalBackendMem
NewLocalBackendMem creates a new LocalBackendMem.
func (*LocalBackendMem) Create ¶ added in v1.55.1
func (l *LocalBackendMem) Create(name string) (LocalBackendFile, error)
Create creates a new file for the given name.
func (*LocalBackendMem) MkdirAll ¶ added in v1.55.1
func (l *LocalBackendMem) MkdirAll(name string, perm os.FileMode) error
MkdirAll recursively creates directories to make name a directory.
func (*LocalBackendMem) Open ¶ added in v1.55.1
func (l *LocalBackendMem) Open(name string) (LocalBackendFile, error)
Open opens the file with the given name.
func (*LocalBackendMem) Remove ¶ added in v1.55.1
func (l *LocalBackendMem) Remove(name string) error
Remove deletes the file with the given name.
func (*LocalBackendMem) Rename ¶ added in v1.55.1
func (l *LocalBackendMem) Rename(oldname, newname string) error
Rename causes the file at oldname to be moved to newname.
type LocalBackendOS ¶ added in v1.55.1
type LocalBackendOS struct{}
LocalBackendOS implements LocalBackend by using the os package.
func NewLocalBackendOS ¶ added in v1.55.1
func NewLocalBackendOS() *LocalBackendOS
NewLocalBackendOS constructs a new LocalBackendOS.
func (*LocalBackendOS) Create ¶ added in v1.55.1
func (l *LocalBackendOS) Create(name string) (LocalBackendFile, error)
Create calls os.Create.
func (*LocalBackendOS) MkdirAll ¶ added in v1.55.1
func (l *LocalBackendOS) MkdirAll(path string, perm os.FileMode) error
MkdirAll calls os.MkdirAll.
func (*LocalBackendOS) Open ¶ added in v1.55.1
func (l *LocalBackendOS) Open(name string) (LocalBackendFile, error)
Open calls os.Open.
func (*LocalBackendOS) Remove ¶ added in v1.55.1
func (l *LocalBackendOS) Remove(name string) error
Remove calls os.Remove.
func (*LocalBackendOS) Rename ¶ added in v1.55.1
func (l *LocalBackendOS) Rename(oldname, newname string) error
Rename calls os.Rename.
type Mixed ¶
type Mixed struct {
// contains filtered or unexported fields
}
Mixed dispatches to either the local or remote filesystem depending on the location.
func NewMixed ¶
func NewMixed(local FilesystemLocal, remote FilesystemRemote) *Mixed
NewMixed returns a Mixed backed by the provided local and remote filesystems.
func (*Mixed) Create ¶
func (m *Mixed) Create(ctx context.Context, loc ulloc.Location, opts *CreateOptions) (WriteHandle, error)
Create returns a WriteHandle to either a local file, remote object, or stdout.
func (*Mixed) IsLocalDir ¶
IsLocalDir returns true if the location is a directory that is local.
func (*Mixed) List ¶
func (m *Mixed) List(ctx context.Context, prefix ulloc.Location, opts *ListOptions) (ObjectIterator, error)
List lists either files and directories with some local path prefix or remote objects with a given bucket and key.
func (*Mixed) Open ¶
Open returns a MultiReadHandle to either a local file, remote object, or stdin.
type MultiReadHandle ¶
type MultiReadHandle interface { io.Closer SetOffset(offset int64) error NextPart(ctx context.Context, length int64) (ReadHandle, error) Info(ctx context.Context) (*ObjectInfo, error) Length() int64 }
MultiReadHandle allows one to read different sections of something. The offset parameter can be negative to signal that the offset should start that many bytes back from the end. Any negative value for length indicates to read up to the end.
TODO: A negative offset requires a negative length, but there is no reason why that must be so.
type ObjectInfo ¶
type ObjectInfo struct { Loc ulloc.Location IsPrefix bool Created time.Time ContentLength int64 Expires time.Time Metadata uplink.CustomMetadata }
ObjectInfo is a simpler *uplink.Object that contains the minimal information the uplink command needs that multiple types can be converted to.
type ObjectIterator ¶
type ObjectIterator interface { Next() bool Err() error Item() ObjectInfo }
ObjectIterator is an interface type for iterating over objectInfo values.
type ReadHandle ¶
type ReadHandle interface { io.Closer io.Reader Info() ObjectInfo }
ReadHandle is something that can be read from distinct parts possibly in parallel.
func NewBufferedReadHandle ¶ added in v1.57.1
func NewBufferedReadHandle(ctx context.Context, reader ReadHandle, buf []byte) ReadHandle
NewBufferedReadHandle wraps reader with buf.
type Remote ¶
type Remote struct {
// contains filtered or unexported fields
}
Remote implements something close to a filesystem but backed by an uplink project.
func NewRemote ¶
NewRemote returns something close to a filesystem and returns objects using the project.
func (*Remote) Create ¶
func (r *Remote) Create(ctx context.Context, bucket, key string, opts *CreateOptions) (WriteHandle, error)
Create returns a MultiWriteHandle for the object identified by a given bucket and key.
func (*Remote) List ¶
func (r *Remote) List(ctx context.Context, bucket, prefix string, opts *ListOptions) ObjectIterator
List lists all of the objects in some bucket that begin with the given prefix.
func (*Remote) Open ¶
Open returns a MultiReadHandle for the object identified by a given bucket and key.
type RemoveOptions ¶
type RemoveOptions struct {
Pending bool
}
RemoveOptions describes options to the Remove command.