Documentation ¶
Overview ¶
Package ulozto provides an interface to the Uloz.to storage system.
Index ¶
- func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, error)
- type DescriptionEncodedMetadata
- type Fs
- func (f *Fs) CreateDir(ctx context.Context, parentSlug, leaf string) (newID string, err error)
- func (f *Fs) DirCacheFlush()
- func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string) error
- func (f *Fs) Features() *fs.Features
- func (f *Fs) FindLeaf(ctx context.Context, folderSlug, leaf string) (leafSlug string, found bool, err error)
- 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) Put(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) 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) ModTime(ctx context.Context) time.Time
- func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (rc io.ReadCloser, err error)
- func (o *Object) Remote() string
- func (o *Object) Remove(ctx context.Context) error
- func (o *Object) SetModTime(ctx context.Context, t 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) error
- type Options
- type RenamingObjectInfoProxy
- func (s *RenamingObjectInfoProxy) Fs() fs.Info
- func (s *RenamingObjectInfoProxy) Hash(ctx context.Context, ty hash.Type) (string, error)
- func (s *RenamingObjectInfoProxy) ModTime(ctx context.Context) time.Time
- func (s *RenamingObjectInfoProxy) Remote() string
- func (s *RenamingObjectInfoProxy) Size() int64
- func (s *RenamingObjectInfoProxy) Storable() bool
- func (s *RenamingObjectInfoProxy) String() string
- type UploadSession
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DescriptionEncodedMetadata ¶
type DescriptionEncodedMetadata struct { Md5Hash []byte // The MD5 hash of the file Sha256Hash []byte // The SHA256 hash of the file ModTimeEpochMicros int64 // The mtime of the file, as set by rclone }
DescriptionEncodedMetadata represents a set of metadata encoded as Uloz.to description.
Uloz.to doesn't support setting metadata such as mtime but allows the user to set an arbitrary description field. The content of this structure will be serialized and stored in the backend.
The files themselves are immutable so there's no danger that the file changes, and we'll forget to update the hashes. It is theoretically possible to rewrite the description to provide incorrect information for a file. However, in case it's a real attack vector, a nefarious person already has write access to the repo, and the situation is above rclone's pay grade already.
type Fs ¶
type Fs struct {
// contains filtered or unexported fields
}
Fs represents a remote uloz.to storage
func (*Fs) CreateDir ¶
CreateDir implements dircache.DirCacher.CreateDir by creating a folder with the given name under a folder identified by parentSlug.
func (*Fs) DirCacheFlush ¶
func (f *Fs) DirCacheFlush()
DirCacheFlush implements the optional fs.DirCacheFlusher interface.
func (*Fs) FindLeaf ¶
func (f *Fs) FindLeaf(ctx context.Context, folderSlug, leaf string) (leafSlug string, found bool, err error)
FindLeaf implements dircache.DirCacher.FindLeaf by successively walking through the folder hierarchy until the desired folder is found, or there's nowhere to continue.
func (*Fs) Hashes ¶
Hashes implements fs.Fs.Hashes by returning the supported hash types of the filesystem.
func (*Fs) Put ¶
func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)
Put implements the mandatory method fs.Fs.Put.
func (*Fs) PutUnchecked ¶
func (f *Fs) PutUnchecked(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error)
PutUnchecked implements the optional interface fs.PutUncheckeder.
Uloz.to allows to have multiple files of the same name in the same folder.
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object describes an uloz.to object.
Valid objects will always have all fields but encodedMetadata set.
func (*Object) Hash ¶
Hash implements the mandatory method fs.Object.Hash.
Supports SHA256 and MD5 hashes.
func (*Object) Open ¶
func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (rc io.ReadCloser, err error)
Open implements the mandatory method fs.Object.Open
func (*Object) SetModTime ¶
SetModTime implements the mandatory method fs.Object.SetModTime
type Options ¶
type Options struct { AppToken string `config:"app_token"` Username string `config:"username"` Password string `config:"password"` RootFolderSlug string `config:"root_folder_slug"` Enc encoder.MultiEncoder `config:"encoding"` ListPageSize int `config:"list_page_size"` }
Options defines the configuration for this backend
type RenamingObjectInfoProxy ¶
type RenamingObjectInfoProxy struct {
// contains filtered or unexported fields
}
RenamingObjectInfoProxy is a delegating proxy for fs.ObjectInfo with the option of specifying a different remote path.
func (*RenamingObjectInfoProxy) Fs ¶
func (s *RenamingObjectInfoProxy) Fs() fs.Info
Fs implements fs.ObjectInfo.Fs by delegating to the wrapped instance.
func (*RenamingObjectInfoProxy) Hash ¶
Hash implements fs.ObjectInfo.Hash by delegating to the wrapped instance.
func (*RenamingObjectInfoProxy) ModTime ¶
func (s *RenamingObjectInfoProxy) ModTime(ctx context.Context) time.Time
ModTime implements fs.ObjectInfo.ModTime by delegating to the wrapped instance.
func (*RenamingObjectInfoProxy) Remote ¶
func (s *RenamingObjectInfoProxy) Remote() string
Remote implements fs.ObjectInfo.Remote by returning the specified remote path.
func (*RenamingObjectInfoProxy) Size ¶
func (s *RenamingObjectInfoProxy) Size() int64
Size implements fs.ObjectInfo.Size by delegating to the wrapped instance.
func (*RenamingObjectInfoProxy) Storable ¶
func (s *RenamingObjectInfoProxy) Storable() bool
Storable implements fs.ObjectInfo.Storable by delegating to the wrapped instance.
func (*RenamingObjectInfoProxy) String ¶
func (s *RenamingObjectInfoProxy) String() string
Remote implements fs.ObjectInfo.Remote by delegating to the wrapped instance.
type UploadSession ¶
UploadSession represents a single Uloz.to upload session.
Uloz.to supports uploading multiple files at once and committing them atomically. This functionality isn't being used by the backend implementation and for simplicity, each session corresponds to a single file being uploaded.