Documentation ¶
Overview ¶
Package hidrive provides an interface to the HiDrive object storage system.
Index ¶
- Constants
- Variables
- func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, error)
- type CopyOrMoveOperationType
- type Fs
- func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object, error)
- func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string) error
- func (f *Fs) Features() *fs.Features
- func (f *Fs) Hashes() hash.Set
- func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err error)
- func (f *Fs) Mkdir(ctx context.Context, dir string) error
- func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object, error)
- func (f *Fs) Name() string
- func (f *Fs) NewObject(ctx context.Context, remote string) (fs.Object, error)
- func (f *Fs) Precision() time.Duration
- func (f *Fs) Purge(ctx context.Context, dir string) error
- func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)
- func (f *Fs) PutStream(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)
- func (f *Fs) PutUnchecked(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)
- func (f *Fs) Rmdir(ctx context.Context, dir string) error
- func (f *Fs) Root() string
- func (f *Fs) Shutdown(ctx context.Context) error
- func (f *Fs) String() string
- type MemberType
- type Object
- func (o *Object) Fs() fs.Info
- func (o *Object) Hash(ctx context.Context, t hash.Type) (string, error)
- func (o *Object) ID() string
- func (o *Object) ModTime(ctx context.Context) time.Time
- func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error)
- func (o *Object) Remote() string
- func (o *Object) Remove(ctx context.Context) error
- func (o *Object) SetModTime(ctx context.Context, modTime time.Time) error
- func (o *Object) Size() int64
- func (o *Object) Storable() bool
- func (o *Object) String() string
- func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) error
- type OnExistAction
- type Options
- type SortByField
Constants ¶
const ( // MaximumUploadBytes represents the maximum amount of bytes // a single upload-operation will support. MaximumUploadBytes = 2147483647 // = 2GiB - 1 )
Variables ¶
var ( // Unsorted disables sorting and can therefore not be combined with other values. Unsorted = []SortByField{"none"} // DefaultSorted does not specify how to sort and // therefore implies the default sort order. DefaultSorted = []SortByField{} )
var ( // ErrorFileExists is returned when a query tries to create a file // that already exists. ErrorFileExists = errors.New("destination file already exists") )
Functions ¶
Types ¶
type CopyOrMoveOperationType ¶
type CopyOrMoveOperationType int
CopyOrMoveOperationType represents the possible types of copy- and move-operations.
const ( MoveOriginal CopyOrMoveOperationType = iota CopyOriginal CopyOriginalPreserveModTime )
possible values for CopyOrMoveOperationType
type Fs ¶
type Fs struct {
// contains filtered or unexported fields
}
Fs represents a remote hidrive.
func (*Fs) Copy ¶
Copy src to this remote using server-side copy operations.
It returns the destination Object and a possible error.
This returns fs.ErrorCantCopy if the operation cannot be performed.
NOTE: If an error occurs when copying the Object, any parent-directories already created will NOT be deleted again.
NOTE: This operation will expand sparse areas in the content of the source-Object to blocks of 0-bytes in the destination-Object.
func (*Fs) DirMove ¶
DirMove moves from src at srcRemote to this remote at dstRemote using server-side move operations.
This returns fs.ErrorCantCopy if the operation cannot be performed. This returns fs.ErrorDirExists if the destination already exists.
NOTE: If an error occurs when moving the directory, any parent-directories already created will NOT be deleted again.
func (*Fs) List ¶
List the objects and directories in dir into entries. The entries can be returned in any order, but should be for a complete directory.
dir should be "" to list the root, and should not have trailing slashes.
This returns fs.ErrorDirNotFound if the directory is not found.
func (*Fs) Mkdir ¶
Mkdir creates the directory if it does not exist.
This will create any missing parent directories.
NOTE: If an error occurs while the parent directories are being created, any directories already created will NOT be deleted again.
func (*Fs) Move ¶
Move src to this remote using server-side move operations.
It returns the destination Object and a possible error.
This returns fs.ErrorCantMove if the operation cannot be performed.
NOTE: If an error occurs when moving the Object, any parent-directories already created will NOT be deleted again.
NOTE: This operation will expand sparse areas in the content of the source-Object to blocks of 0-bytes in the destination-Object.
func (*Fs) NewObject ¶
NewObject finds the Object at remote.
If remote points to a directory then it returns fs.ErrorIsDir. If it can not be found it returns the error fs.ErrorObjectNotFound.
func (*Fs) Purge ¶
Purge removes the directory and all of its contents.
This returns fs.ErrorDirectoryNotEmpty if the directory is not empty.
func (*Fs) Put ¶
func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)
Put the contents of the io.Reader into the remote path with the modTime given of the given size. The existing or new object is returned.
A new object may have been created or an existing one accessed even if an error is returned, in which case both the object and the error will be returned.
func (*Fs) PutStream ¶
func (f *Fs) PutStream(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)
PutStream uploads the contents of the io.Reader to the remote path with the modTime given of indeterminate size. The existing or new object is returned.
A new object may have been created or an existing one accessed even if an error is returned, in which case both the object and the error will be returned.
func (*Fs) PutUnchecked ¶
func (f *Fs) PutUnchecked(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)
PutUnchecked the contents of the io.Reader into the remote path with the modTime given of the given size. This guarantees that existing objects will not be overwritten. The new object is returned.
This will produce an error if an object already exists at that path.
In case the upload fails and an object has been created, this will try to delete the object at that path. In case the failed upload could not be deleted, both the object and the (upload-)error will be returned.
func (*Fs) Rmdir ¶
Rmdir removes the directory if empty.
This returns fs.ErrorDirNotFound if the directory is not found. This returns fs.ErrorDirectoryNotEmpty if the directory is not empty.
type MemberType ¶
type MemberType string
MemberType represents the possible types of entries a directory can contain.
const ( AllMembers MemberType = "all" NoMembers MemberType = "none" DirectoryMembers MemberType = api.HiDriveObjectTypeDirectory FileMembers MemberType = api.HiDriveObjectTypeFile SymlinkMembers MemberType = api.HiDriveObjectTypeSymlink )
possible values for MemberType
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object describes a hidrive object.
Will definitely have the remote-path but may lack meta-information.
func (*Object) Hash ¶
Hash returns the selected checksum of the file. If no checksum is available it returns "".
func (*Object) Open ¶
func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error)
Open an object for reading.
func (*Object) SetModTime ¶
SetModTime sets the metadata on the object to set the modification date.
func (*Object) Update ¶
func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) error
Update the existing object with the contents of the io.Reader, modTime and size.
For unknown-sized contents (indicated by src.Size() == -1) this will try to properly upload it in multiple chunks.
type OnExistAction ¶
type OnExistAction string
OnExistAction represents possible actions the API should take, when a request tries to create a path that already exists.
const ( // IgnoreOnExist instructs the API not to execute // the request in case of a conflict, but to return an error. IgnoreOnExist OnExistAction = "ignore" // AutoNameOnExist instructs the API to automatically rename // any conflicting request-objects. AutoNameOnExist OnExistAction = "autoname" // OverwriteOnExist instructs the API to overwrite any conflicting files. // This can only be used, if the request operates on files directly. // (For example when moving/copying a file.) // For most requests this action will simply be ignored. OverwriteOnExist OnExistAction = "overwrite" )
possible values for OnExistAction
type Options ¶
type Options struct { EndpointAPI string `config:"endpoint"` OptionalMemberCountDisabled bool `config:"disable_fetching_member_count"` UploadChunkSize fs.SizeSuffix `config:"chunk_size"` UploadCutoff fs.SizeSuffix `config:"upload_cutoff"` UploadConcurrency int64 `config:"upload_concurrency"` Enc encoder.MultiEncoder `config:"encoding"` RootPrefix string `config:"root_prefix"` ScopeAccess string `config:"scope_access"` ScopeRole string `config:"scope_role"` }
Options defines the configuration for this backend.
type SortByField ¶
type SortByField string
SortByField represents possible fields to sort entries of a directory by.
const ( SortByName SortByField = "name" SortByModTime SortByField = "mtime" SortByObjectType SortByField = "type" SortBySize SortByField = "size" SortByNameDescending SortByField = SortByField(descendingSort) + SortByName SortByModTimeDescending SortByField = SortByField(descendingSort) + SortByModTime SortByObjectTypeDescending SortByField = SortByField(descendingSort) + SortByObjectType SortBySizeDescending SortByField = SortByField(descendingSort) + SortBySize )
possible values for SortByField
Directories ¶
Path | Synopsis |
---|---|
Package api has type definitions and code related to API-calls for the HiDrive-API.
|
Package api has type definitions and code related to API-calls for the HiDrive-API. |
Package hidrivehash implements the HiDrive hashing algorithm which combines SHA-1 hashes hierarchically to a single top-level hash.
|
Package hidrivehash implements the HiDrive hashing algorithm which combines SHA-1 hashes hierarchically to a single top-level hash. |
internal
Package internal provides utilities for HiDrive.
|
Package internal provides utilities for HiDrive. |