filen

package
v0.0.0-...-11ccece Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package filen provides an SDK interface to interact with the cloud drive.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Directory

type Directory struct {
	UUID       string    // the UUID of the cloud item
	Name       string    // the directory name
	ParentUUID string    // the [Directory.UUID] of the directory's parent directory (or zero value for the root directory)
	Color      string    // the color assigned to the directory (zero value means default color)
	Created    time.Time // when the directory was created
	Favorited  bool      // whether the directory is marked a favorite
}

Directory represents a directory on the cloud drive.

type File

type File struct {
	UUID          string    // the UUID of the cloud item
	Name          string    // the file name
	Size          int64     // the file size in bytes
	MimeType      string    // the MIME type of the file
	EncryptionKey []byte    // the key used to encrypt the file data
	Created       time.Time // when the file was created
	LastModified  time.Time // when the file was last modified
	ParentUUID    string    // the [Directory.UUID] of the file's parent directory
	Favorited     bool      // whether the file is marked a favorite
	Region        string    // the file's storage region
	Bucket        string    // the file's storage bucket
	Chunks        int       // how many 1 MiB chunks the file is partitioned into
}

File represents a file on the cloud drive.

type Filen

type Filen struct {

	// MasterKeys contains the crypto master keys for the current user. When the user changes
	// their password, a new master key is appended. For decryption, all master keys are tried
	// until one works; for decryption, always use the latest master key.
	MasterKeys [][]byte
	// contains filtered or unexported fields
}

Filen provides the SDK interface. Needs to be initialized via New.

func New

func New(email, password string) (*Filen, error)

New creates a new Filen and initializes it with the given email and password by logging in with the API and preparing the API key and master keys.

func (*Filen) CurrentMasterKey

func (filen *Filen) CurrentMasterKey() []byte

CurrentMasterKey returns the current master key to use for encryption. Multiple possible master keys exist for decryption, but only the latest one should be used for encryption.

func (*Filen) DownloadFile

func (filen *Filen) DownloadFile(file *File, chunkHandler func(chunk int, data []byte) error) error

DownloadFile downloads a file from the cloud drive and calls the chunkHandler for every received chunk.

func (*Filen) DownloadFileInMemory

func (filen *Filen) DownloadFileInMemory(file *File) ([]byte, error)

DownloadFileInMemory downloads a file from the cloud drive and stores its bytes in memory.

func (*Filen) DownloadFileToDisk

func (filen *Filen) DownloadFileToDisk(file *File, destination *os.File) error

DownloadFileToDisk downloads a file from the cloud drive into a local destination on disk.

func (*Filen) GetBaseFolderUUID

func (filen *Filen) GetBaseFolderUUID() (string, error)

GetBaseFolderUUID fetches the UUID of the cloud drive's root directory.

func (*Filen) PathToUUID

func (filen *Filen) PathToUUID(path string, requireDirectory bool) (string, error)

PathToUUID identifies a cloud item by its path and returns its UUID. Set the requireDirectory to differentiate between files and directories with the same path (otherwise, the file will be found).

func (*Filen) ReadDirectory

func (filen *Filen) ReadDirectory(uuid string) ([]*File, []*Directory, error)

ReadDirectory fetches the files and directories that are children of a directory (specified by UUID).

func (*Filen) UploadFile

func (filen *Filen) UploadFile(source *os.File, parentUUID string) error

UploadFile uploads a local file (specified by path) to a cloud directory (specified by UUID).

Directories

Path Synopsis
Package client handles HTTP requests to the API and storage backends.
Package client handles HTTP requests to the API and storage backends.
Package crypto provides the cryptographic functions required within the SDK.
Package crypto provides the cryptographic functions required within the SDK.

Jump to

Keyboard shortcuts

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