Documentation ¶
Overview ¶
Package pixeldrain provides an interface to the Pixeldrain object storage system.
Index ¶
- func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, error)
- type APIError
- type ChangeLog
- type ChangeLogEntry
- type FilesystemNode
- type FilesystemPath
- type Fs
- func (f *Fs) About(ctx context.Context) (usage *fs.Usage, err error)
- func (f *Fs) ChangeNotify(ctx context.Context, notify func(string, fs.EntryType), ...)
- func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string) (err error)
- func (f *Fs) DirSetModTime(ctx context.Context, dir string, modTime time.Time) (err 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) (err 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) PublicLink(ctx context.Context, remote string, expire fs.Duration, unlink bool) (string, error)
- func (f *Fs) Purge(ctx context.Context, dir string) (err 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) Rmdir(ctx context.Context, dir string) (err error)
- func (f *Fs) Root() string
- func (f *Fs) String() string
- type Object
- func (o *Object) Fs() fs.Info
- func (o *Object) Hash(ctx context.Context, t hash.Type) (string, error)
- func (o *Object) Metadata(ctx context.Context) (fs.Metadata, error)
- func (o *Object) MimeType(ctx context.Context) string
- func (o *Object) ModTime(ctx context.Context) time.Time
- func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.ReadCloser, err error)
- func (o *Object) Remote() string
- func (o *Object) Remove(ctx context.Context) error
- func (o *Object) SetModTime(ctx context.Context, modTime time.Time) (err 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) (err error)
- type Options
- type SubscriptionType
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ChangeLog ¶
type ChangeLog []ChangeLogEntry
ChangeLog is a log of changes that happened in a filesystem. Changes returned from the API are on chronological order from old to new. A change log can be requested for any directory or file, but change logging needs to be enabled with the update API before any log entries will be made. Changes are logged for 24 hours after logging was enabled. Each time a change log is requested the timer is reset to 24 hours.
type ChangeLogEntry ¶
type ChangeLogEntry struct { Time time.Time `json:"time"` Path string `json:"path"` PathNew string `json:"path_new"` Action string `json:"action"` Type string `json:"type"` }
ChangeLogEntry is a single entry in a directory's change log. It contains the time at which the change occurred. The path relative to the requested directory and the action that was performend (update, move or delete). In case of a move operation the new path of the file is stored in the path_new field
type FilesystemNode ¶
type FilesystemNode struct { Type string `json:"type"` Path string `json:"path"` Name string `json:"name"` Created time.Time `json:"created"` Modified time.Time `json:"modified"` ModeOctal string `json:"mode_octal"` // File params FileSize int64 `json:"file_size"` FileType string `json:"file_type"` SHA256Sum string `json:"sha256_sum"` // ID is only filled in when the file/directory is publicly shared ID string `json:"id,omitempty"` }
FilesystemNode is a single node in the pixeldrain filesystem. Usually part of a Path or Children slice. The Node is also returned as response from update commands, if requested
type FilesystemPath ¶
type FilesystemPath struct { Path []FilesystemNode `json:"path"` BaseIndex int `json:"base_index"` Children []FilesystemNode `json:"children"` }
FilesystemPath is the object which is returned from the pixeldrain API when running the stat command on a path. It includes the node information for all the members of the path and for all the children of the requested directory.
func (*FilesystemPath) Base ¶
func (fsp *FilesystemPath) Base() FilesystemNode
Base returns the base node of the path, this is the node that the path points to
type Fs ¶
type Fs struct {
// contains filtered or unexported fields
}
Fs represents a remote box
func (*Fs) ChangeNotify ¶
func (f *Fs) ChangeNotify(ctx context.Context, notify func(string, fs.EntryType), newInterval <-chan time.Duration)
ChangeNotify calls the passed function with a path that has had changes. If the implementation uses polling, it should adhere to the given interval. At least one value will be written to the channel, specifying the initial value and updated values might follow. A 0 Duration should pause the polling. The ChangeNotify implementation must empty the channel regularly. When the channel gets closed, the implementation should stop polling and release resources.
func (*Fs) DirMove ¶
DirMove moves src, srcRemote to this remote at dstRemote using server-side move operations.
Will only be called if src.Fs().Name() == f.Name()
If it isn't possible then return fs.ErrorCantDirMove
If destination exists then return fs.ErrorDirExists
func (*Fs) DirSetModTime ¶
DirSetModTime sets the mtime metadata on a directory
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 should return ErrDirNotFound if the directory isn't found.
func (*Fs) Move ¶
Move src to this remote using server-side move operations.
This is stored with the remote path given.
It returns the destination Object and a possible error.
Will only be called if src.Fs().Name() == f.Name()
If it isn't possible then return fs.ErrorCantMove
func (*Fs) NewObject ¶
NewObject finds the Object at remote. If it can't be found it returns the error fs.ErrorObjectNotFound.
func (*Fs) PublicLink ¶
func (f *Fs) PublicLink(ctx context.Context, remote string, expire fs.Duration, unlink bool) (string, error)
PublicLink generates a public link to the remote path (usually readable by anyone)
func (*Fs) Purge ¶
Purge all files in the directory specified
Implement this if you have a way of deleting all the files quicker than just running Remove() on the result of List()
Return an error if it doesn't exist
func (*Fs) Put ¶
func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)
Put the object
Copy the reader in to the new object which is returned.
The new object may have been created if an error is 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 to the remote path with the modTime given of indeterminate size
May create the object even if it returns an error - if so will return the object and the error, otherwise will return nil and the error
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object describes a pixeldrain file
func (*Object) Metadata ¶
Metadata returns metadata for an object
It should return nil if there is no Metadata
func (*Object) ModTime ¶
ModTime returns the modification time of the object
It attempts to read the objects mtime and if that isn't present the LastModified returned in the http headers
func (*Object) Open ¶
func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.ReadCloser, err error)
Open an object for read
func (*Object) SetModTime ¶
SetModTime sets the modification time of the local fs object
func (*Object) Update ¶
func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (err error)
Update the object with the contents of the io.Reader, modTime and size
If existing is set then it updates the object rather than creating a new one.
The new object may have been created if an error is returned.
type Options ¶
type Options struct { APIKey string `config:"api_key"` RootFolderID string `config:"root_folder_id"` APIURL string `config:"api_url"` }
Options defines the configuration for this backend
type SubscriptionType ¶
type SubscriptionType struct { Name string `json:"name"` StorageSpace int64 `json:"storage_space"` }
SubscriptionType contains information about a subscription type. It's not the active subscription itself, only the properties of the subscription. Like the perks and cost
type UserInfo ¶
type UserInfo struct { Username string `json:"username"` Subscription SubscriptionType `json:"subscription"` StorageSpaceUsed int64 `json:"storage_space_used"` }
UserInfo contains information about the logged in user