ulozto

package
v1.67.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package ulozto provides an interface to the Uloz.to 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 a Fs from the path, container:path

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

func (f *Fs) CreateDir(ctx context.Context, parentSlug, leaf string) (newID string, err error)

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

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

DirMove implements the optional method fs.DirMover.DirMove.

func (*Fs) Features

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

Features returns the optional features of this Fs

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

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

Hashes implements fs.Fs.Hashes by returning the supported hash types of the filesystem.

func (*Fs) List

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

List implements fs.Fs.List by listing all files and folders in the given folder.

func (*Fs) Mkdir

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

Mkdir implements the mandatory method fs.Fs.Mkdir.

func (*Fs) Move

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

Move implements the optional method fs.Mover.Move.

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 implements fs.Fs.NewObject.

func (*Fs) Precision

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

Precision return the precision of this Fs

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.

func (*Fs) Rmdir

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

Rmdir implements the mandatory method fs.Fs.Rmdir.

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 an uloz.to object.

Valid objects will always have all fields but encodedMetadata set.

func (*Object) Fs

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

Fs implements the mandatory method fs.Object.Fs

func (*Object) Hash

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

Hash implements the mandatory method fs.Object.Hash.

Supports SHA256 and MD5 hashes.

func (*Object) ModTime

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

ModTime implements the mandatory method fs.Object.ModTime

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

func (o *Object) Remote() string

Remote returns the remote path

func (*Object) Remove

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

Remove implements the mandatory method fs.Object.Remove

func (*Object) SetModTime

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

SetModTime implements the mandatory method fs.Object.SetModTime

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 implements the mandatory method fs.ObjectInfo.Storable

func (*Object) String

func (o *Object) String() string

String returns the string representation of the remote object reference.

func (*Object) Update

func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) error

Update implements the mandatory method fs.Object.Update

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

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

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

type UploadSession struct {
	Filesystem  *Fs
	URL         string
	PrivateSlug string
	ValidUntil  time.Time
}

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.

Directories

Path Synopsis
Package api has type definitions for uloz.to
Package api has type definitions for uloz.to

Jump to

Keyboard shortcuts

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