Documentation
¶
Overview ¶
Package client handles HTTP requests to the API and storage backends.
API definitions are at https://gateway.filen.io/v3/docs.
Index ¶
- Constants
- type Client
- func (c *Client) DownloadFileChunk(ctx context.Context, uuid string, region string, bucket string, chunkIdx int) ([]byte, error)
- func (c *Client) GetV3UserBaseFolder(ctx context.Context) (*V3UserBaseFolderResponse, error)
- func (c *Client) GetV3UserDEK(ctx context.Context) (crypto.EncryptedString, error)
- func (c *Client) PostV3DirContent(ctx context.Context, uuid string) (*V3DirContentResponse, error)
- func (c *Client) PostV3DirCreate(ctx context.Context, uuid string, name crypto.EncryptedString, ...) (*V3CreateDirResponse, error)
- func (c *Client) PostV3DirTrash(ctx context.Context, uuid string) error
- func (c *Client) PostV3FileMetadata(ctx context.Context, uuid string, name crypto.EncryptedString, ...) error
- func (c *Client) PostV3FileTrash(ctx context.Context, uuid string) error
- func (c *Client) PostV3Upload(ctx context.Context, uuid string, chunkIdx int, parentUUID string, ...) (*V3UploadResponse, error)
- func (c *Client) PostV3UploadDone(ctx context.Context, request V3UploadDoneRequest) (*V3UploadDoneResponse, error)
- func (c *Client) PostV3UploadEmpty(ctx context.Context, request V3UploadEmptyRequest) (*V3UploadDoneResponse, error)
- func (c *Client) PostV3UserDEK(ctx context.Context, encryptedDEK crypto.EncryptedString) error
- func (c *Client) PostV3UserMasterKeys(ctx context.Context, encryptedMasterKey crypto.EncryptedString) (*V3UserMasterKeysResponse, error)
- func (c *Client) Request(ctx context.Context, method string, url *FilenURL, requestData any) (*aPIResponse, error)
- func (c *Client) RequestData(ctx context.Context, method string, url *FilenURL, requestData any, ...) (*aPIResponse, error)
- type FilenURL
- type RequestError
- type UnauthorizedClient
- func (uc *UnauthorizedClient) Authorize(apiKey string) *Client
- func (uc *UnauthorizedClient) PostV3AuthInfo(ctx context.Context, email string) (*V3AuthInfoResponse, error)
- func (uc *UnauthorizedClient) PostV3Login(ctx context.Context, email string, password crypto.DerivedPassword) (*V3LoginResponse, error)
- func (uc *UnauthorizedClient) Request(ctx context.Context, method string, url *FilenURL, requestData any) (*aPIResponse, error)
- func (uc *UnauthorizedClient) RequestData(ctx context.Context, method string, url *FilenURL, requestData any, ...) (*aPIResponse, error)
- type V3AuthInfoResponse
- type V3CreateDirResponse
- type V3DirContentResponse
- type V3LoginResponse
- type V3UploadDoneRequest
- type V3UploadDoneResponse
- type V3UploadEmptyRequest
- type V3UploadResponse
- type V3UserBaseFolderResponse
- type V3UserMasterKeysResponse
Constants ¶
View Source
const ( URLTypeIngest = 1 URLTypeEgest = 2 URLTypeGateway = 3 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { APIKey string // the Filen API key }
func (*Client) DownloadFileChunk ¶
func (c *Client) DownloadFileChunk(ctx context.Context, uuid string, region string, bucket string, chunkIdx int) ([]byte, error)
DownloadFileChunk downloads a file chunk from the storage backend.
func (*Client) GetV3UserBaseFolder ¶ added in v0.0.5
func (c *Client) GetV3UserBaseFolder(ctx context.Context) (*V3UserBaseFolderResponse, error)
GetV3UserBaseFolder calls /v3/user/baseFolder.
func (*Client) GetV3UserDEK ¶ added in v0.0.5
func (*Client) PostV3DirContent ¶ added in v0.0.5
PostV3DirContent calls /v3/dir/content.
func (*Client) PostV3DirCreate ¶ added in v0.0.5
func (c *Client) PostV3DirCreate(ctx context.Context, uuid string, name crypto.EncryptedString, nameHashed string, parentUUID string) (*V3CreateDirResponse, error)
PostV3DirCreate calls /v3/dir/create
func (*Client) PostV3DirTrash ¶ added in v0.0.5
func (*Client) PostV3FileMetadata ¶ added in v0.0.5
func (c *Client) PostV3FileMetadata(ctx context.Context, uuid string, name crypto.EncryptedString, nameHashed string, metadata crypto.EncryptedString) error
func (*Client) PostV3FileTrash ¶ added in v0.0.5
func (*Client) PostV3Upload ¶ added in v0.0.5
func (c *Client) PostV3Upload(ctx context.Context, uuid string, chunkIdx int, parentUUID string, uploadKey string, data []byte) (*V3UploadResponse, error)
PostV3Upload uploads a file chunk to the storage backend.
func (*Client) PostV3UploadDone ¶ added in v0.0.5
func (c *Client) PostV3UploadDone(ctx context.Context, request V3UploadDoneRequest) (*V3UploadDoneResponse, error)
PostV3UploadDone calls /v3/upload/done.
func (*Client) PostV3UploadEmpty ¶ added in v0.0.7
func (c *Client) PostV3UploadEmpty(ctx context.Context, request V3UploadEmptyRequest) (*V3UploadDoneResponse, error)
func (*Client) PostV3UserDEK ¶ added in v0.0.5
func (*Client) PostV3UserMasterKeys ¶ added in v0.0.5
func (c *Client) PostV3UserMasterKeys(ctx context.Context, encryptedMasterKey crypto.EncryptedString) (*V3UserMasterKeysResponse, error)
PostV3UserMasterKeys calls /v3/user/masterKeys.
type FilenURL ¶ added in v0.0.5
func GatewayURL ¶ added in v0.0.5
type RequestError ¶
type RequestError struct { Message string // description of where the error occurred Method string // HTTP method of the request URL *FilenURL // URL path of the request UnderlyingError error // the underlying error }
A RequestError carries information on a failed HTTP request.
func (*RequestError) Error ¶
func (e *RequestError) Error() string
type UnauthorizedClient ¶ added in v0.0.5
type UnauthorizedClient struct {
// contains filtered or unexported fields
}
func New ¶ added in v0.0.5
func New() *UnauthorizedClient
func (*UnauthorizedClient) Authorize ¶ added in v0.0.5
func (uc *UnauthorizedClient) Authorize(apiKey string) *Client
func (*UnauthorizedClient) PostV3AuthInfo ¶ added in v0.0.5
func (uc *UnauthorizedClient) PostV3AuthInfo(ctx context.Context, email string) (*V3AuthInfoResponse, error)
PostV3AuthInfo calls /v3/auth/info.
func (*UnauthorizedClient) PostV3Login ¶ added in v0.0.5
func (uc *UnauthorizedClient) PostV3Login(ctx context.Context, email string, password crypto.DerivedPassword) (*V3LoginResponse, error)
PostV3Login calls /v3/login.
func (*UnauthorizedClient) RequestData ¶ added in v0.0.5
type V3AuthInfoResponse ¶ added in v0.0.5
type V3CreateDirResponse ¶ added in v0.0.5
type V3CreateDirResponse struct {
UUID string `json:"uuid"`
}
type V3DirContentResponse ¶ added in v0.0.5
type V3DirContentResponse struct { Uploads []struct { UUID string `json:"uuid"` Metadata crypto.EncryptedString `json:"metadata"` Rm string `json:"rm"` Timestamp int `json:"timestamp"` Chunks int `json:"chunks"` Size int `json:"size"` Bucket string `json:"bucket"` Region string `json:"region"` Parent string `json:"parent"` Version int `json:"version"` Favorited int `json:"favorited"` } `json:"uploads"` Folders []struct { UUID string `json:"uuid"` Name crypto.EncryptedString `json:"name"` Parent string `json:"parent"` Color types.DirColor `json:"color"` Timestamp int `json:"timestamp"` Favorited int `json:"favorited"` IsSync int `json:"is_sync"` IsDefault int `json:"is_default"` } `json:"folders"` }
type V3LoginResponse ¶ added in v0.0.5
type V3LoginResponse struct { APIKey string `json:"apiKey"` MasterKeys crypto.EncryptedString `json:"masterKeys"` PublicKey string `json:"publicKey"` PrivateKey crypto.EncryptedString `json:"privateKey"` DEK crypto.EncryptedString `json:"dek"` }
type V3UploadDoneRequest ¶ added in v0.0.5
type V3UploadDoneRequest struct { V3UploadEmptyRequest Chunks int `json:"chunks"` Rm string `json:"rm"` UploadKey string `json:"uploadKey"` }
type V3UploadDoneResponse ¶ added in v0.0.5
type V3UploadEmptyRequest ¶ added in v0.0.7
type V3UploadEmptyRequest struct { UUID string `json:"uuid"` Name crypto.EncryptedString `json:"name"` NameHashed string `json:"nameHashed"` Size string `json:"size"` Parent string `json:"parent"` MimeType crypto.EncryptedString `json:"mime"` Metadata crypto.EncryptedString `json:"metadata"` Version int `json:"version"` }
type V3UploadResponse ¶ added in v0.0.9
type V3UserBaseFolderResponse ¶ added in v0.0.5
type V3UserBaseFolderResponse struct {
UUID string `json:"uuid"`
}
type V3UserMasterKeysResponse ¶ added in v0.0.5
type V3UserMasterKeysResponse struct {
Keys crypto.EncryptedString `json:"keys"`
}
Click to show internal directories.
Click to hide internal directories.