pixeldrain

package
v1.68.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package pixeldrain provides an interface to the Pixeldrain object storage system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFs

func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, error)

NewFs constructs an Fs from the path, container:path

Types

type APIError

type APIError struct {
	StatusCode string `json:"value"`
	Message    string `json:"message"`
}

APIError is the error type returned by the pixeldrain API

func (APIError) Error

func (e APIError) Error() string

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) About

func (f *Fs) About(ctx context.Context) (usage *fs.Usage, err error)

About gets quota information

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

func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string) (err error)

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

func (f *Fs) DirSetModTime(ctx context.Context, dir string, modTime time.Time) (err error)

DirSetModTime sets the mtime metadata on a directory

func (*Fs) Features

func (f *Fs) Features() *fs.Features

Features returns the optional features of this Fs

func (*Fs) Hashes

func (f *Fs) Hashes() hash.Set

Hashes returns the supported hash sets.

func (*Fs) List

func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err error)

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) Mkdir

func (f *Fs) Mkdir(ctx context.Context, dir string) (err error)

Mkdir creates the container if it doesn't exist

func (*Fs) Move

func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object, error)

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) Name

func (f *Fs) Name() string

Name of the remote (as passed into NewFs)

func (*Fs) NewObject

func (f *Fs) NewObject(ctx context.Context, remote string) (fs.Object, error)

NewObject finds the Object at remote. If it can't be found it returns the error fs.ErrorObjectNotFound.

func (*Fs) Precision

func (f *Fs) Precision() time.Duration

Precision return the precision of this Fs

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

func (f *Fs) Purge(ctx context.Context, dir string) (err error)

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

func (*Fs) Rmdir

func (f *Fs) Rmdir(ctx context.Context, dir string) (err error)

Rmdir deletes the root folder

Returns an error if it isn't empty

func (*Fs) Root

func (f *Fs) Root() string

Root of the remote (as passed into NewFs)

func (*Fs) String

func (f *Fs) String() string

String converts this Fs to a string

type Object

type Object struct {
	// contains filtered or unexported fields
}

Object describes a pixeldrain file

func (*Object) Fs

func (o *Object) Fs() fs.Info

Fs returns the parent Fs

func (*Object) Hash

func (o *Object) Hash(ctx context.Context, t hash.Type) (string, error)

Hash returns the SHA-256 of an object returning a lowercase hex string

func (*Object) Metadata

func (o *Object) Metadata(ctx context.Context) (fs.Metadata, error)

Metadata returns metadata for an object

It should return nil if there is no Metadata

func (*Object) MimeType

func (o *Object) MimeType(ctx context.Context) string

MimeType returns the content type of the Object if known, or "" if not

func (*Object) ModTime

func (o *Object) ModTime(ctx context.Context) time.Time

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) Remote

func (o *Object) Remote() string

Remote returns the remote path

func (*Object) Remove

func (o *Object) Remove(ctx context.Context) error

Remove an object

func (*Object) SetModTime

func (o *Object) SetModTime(ctx context.Context, modTime time.Time) (err error)

SetModTime sets the modification time of the local fs object

func (*Object) Size

func (o *Object) Size() int64

Size returns the size of an object in bytes

func (*Object) Storable

func (o *Object) Storable() bool

Storable returns a boolean showing whether this object storable

func (*Object) String

func (o *Object) String() string

Return a string version

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL