ydfs

package module
v0.0.0-...-1ada8dc Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: MIT Imports: 13 Imported by: 0

README

ydfs

Implementation of Yandex Disk REST API with fs.Fs interface

This is a work in progress. ReadFile, WriteFile, Open (and Read of File), Remove, Mkdir work as expected. Test coverage is around 60% (integration tests are passing without errors). Hold on a while :)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNetwork  = errors.New("network error")
	ErrAPI      = errors.New("API error")
	ErrNotFound = errors.New("resource not found")
	ErrUnknown  = errors.New("unknown error")
	ErrInternal = errors.New("internal error")
)

Functions

This section is empty.

Types

type CommentIDs

type CommentIDs struct {
	PrivateResourceID string `json:"private_resource,omitempty"`
	PublicResourseID  string `json:"public_resource,omitempty"`
}

type FS

type FS interface {
	// Open opens the named file.
	Open(name string) (fs.File, error)

	// Stat returns a FileInfo describing the named file from the file system.
	Stat(name string) (fs.FileInfo, error)

	// Sub returns an FS corresponding to the subtree rooted at dir.
	Sub(dir string) (FS, error)

	// ReadFile reads the named file and returns its contents.
	// A successful call returns a nil error, not io.EOF.
	// (Because ReadFile reads the whole file, the expected EOF
	// from the final Read is not treated as an error to be reported.)
	//
	// The caller is permitted to modify the returned byte slice.
	// This method should return a copy of the underlying data.
	ReadFile(name string) ([]byte, error)

	// ReadDir reads the named directory
	// and returns a list of directory entries sorted by filename.
	ReadDir(name string) ([]fs.DirEntry, error)

	// WriteFile writes data to the named file, creating it if necessary.
	// If the file does not exist, WriteFile creates it
	// otherwise WriteFile truncates it before writing.
	WriteFile(name string, data []byte) error

	// Mkdir creates a new directory with the specified name
	Mkdir(name string) error

	// MkdirAll creates a directory named path, along with any necessary parents,
	// and returns nil, or else returns an error.
	MkdirAll(path string) error

	// Remove removes the named file or (empty) directory.
	Remove(name string) error

	// RemoveAll removes path and any children it contains. It removes everything it can
	// but returns the first error it encounters. If the path does not exist,
	// RemoveAll returns nil (no error).
	RemoveAll(path string) error
}

FS provides access to files stored in Yandex Disk. It complies with fs.FS, fs.GlobFS, fs.ReadDirFS, fs.ReadFileFS, fs.StatFS, fs.SubFS interfaces of standard library. FS has additional methods specific to metainformation stored by Yandex - see DiskInfo and UserInfo methods.

func New

func New(token string, client *http.Client) (FS, error)

New returns ydfs.FS which is compliant with standard library's fs.FS interface. Token is required for authorization. Pre-configured http.Client can be supplied (e.g. with timeout set to specific value). If client is nil then http.DefaultClient is used.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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