mod

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetFileInfo

type GetFileInfo struct {
	// Password for this file
	Password string
	// the file token
	Token string
	// the filename and the file upload epoch. for example, 1710111505084/08.png.
	// files with hidden filenames will only contain the epoch with ext. for example, 1710111505084.png
	Filename string
}

type ModifyEntryPayload added in v1.6.0

type ModifyEntryPayload struct {

	// The new password.
	// If the file is not currently encrypted, then this will encrypt it with the new password if it is encrypted, Then this will change the password (`previousPassword` will need to be set in this case)
	// set this to an empty string `""` to remove protection and decrypt the file
	Password *string `json:"password"`

	// If changing a password, then this will need to be set
	PreviousPassword *string `json:"previousPassword"`

	// same as WaifuvaultPutOpts.Expires
	CustomExpiry *string `json:"customExpiry"`

	// hide the filename. use the new URL in the response to get the new URL to use
	HideFilename *bool `json:"hideFilename"`
}

ModifyEntryPayload A modify entry request to change aspects of the entry

type WaifuBucket added in v1.8.0

type WaifuBucket struct {
	// the token of the bucket
	Token string `json:"token"`

	// The files contained in this bucket
	Files []WaifuResponse[int] `json:"files"`
}

type WaifuError

type WaifuError struct {
	Name    string // The name of the HTTP status. e.g: Bad Request
	Message string // the message or reason why the request failed
	Status  int    // the http status returned
}

type WaifuResponse

type WaifuResponse[T string | int] struct {

	// Token for the uploaded file
	Token string `json:"token"`

	// URL to the uploaded file
	URL string `json:"url"`

	// Options The options for this upload
	Options WaifuResponseOptions `json:"options"`

	// RetentionPeriod is a string or a number that represents
	// when the file will expire, if called with `format` true, then
	// this will be a string like "332 days 7 hours 18 minutes 8 seconds"
	RetentionPeriod T `json:"retentionPeriod"`

	// Bucket - the bucket this belongs to
	Bucket string `json:"bucket"`
}

WaifuResponse is the response from the api for files and uploads

type WaifuResponseOptions added in v1.6.1

type WaifuResponseOptions struct {
	// HideFilename If the filename is hidden
	HideFilename bool `json:"hideFilename"`

	// OneTimeDownload  If this file will be deleted when it is accessed
	OneTimeDownload bool `json:"oneTimeDownload"`

	// Protected is if this file is protected-protected/encrypted
	Protected bool `json:"protected"`
}

type Waifuvalt

type Waifuvalt interface {
	// UploadFile - Upload a file using a byte array, url or file
	UploadFile(ctx context.Context, options WaifuvaultPutOpts) (*WaifuResponse[string], error)

	// FileInfo - Obtain file info such as URL and retention period (as an epoch timestamp)
	FileInfo(ctx context.Context, token string) (*WaifuResponse[int], error)

	// FileInfoFormatted - Same as FileInfo, but instead returns the retention period as a human-readable string
	FileInfoFormatted(ctx context.Context, token string) (*WaifuResponse[string], error)

	// DeleteFile - Delete a file given a token
	DeleteFile(ctx context.Context, token string) (bool, error)

	// GetFile - Download the file given options and return a byte array of said file
	GetFile(ctx context.Context, options GetFileInfo) ([]byte, error)

	// ModifyFile - modify an entry
	ModifyFile(ctx context.Context, token string, options ModifyEntryPayload) (*WaifuResponse[int], error)

	// CreateBucket - create a new bucket, buckets are bound to your IP, so you may only have one bucket per IP
	CreateBucket(ctx context.Context) (*WaifuBucket, error)

	// GetBucket - Get a bucket and all the files it contains
	GetBucket(ctx context.Context, token string) (*WaifuBucket, error)

	// DeleteBucket - Delete a bucket and all files it contains
	DeleteBucket(ctx context.Context, token string) (bool, error)
}

type WaifuvaultPutOpts

type WaifuvaultPutOpts struct {

	// A string containing a number and a letter of `m` for mins, `h` for hours, `d` for days.
	// For example, `1h` would be 1 hour and `1d` would be 1 day.
	// Omit this if you want the file to exist, according to the retention policy
	Expires string

	// if set to true, then your filename will not appear in the URL. if false, then it will appear in the URL. defaults to false
	HideFilename bool

	// Setting a password will encrypt the file
	Password string

	//The file object on disk
	File *os.File

	// the raw bytes of the file
	Bytes *[]byte

	//An url to the file you want uploaded
	Url string

	// The filename if `Bytes` is used
	FileName string

	// If this is true, then the file will be deleted as soon as it is accessed
	OneTimeDownload bool `json:"oneTimeDownload"`

	// If supplied, this file will be associated to that bucket
	BucketToken string
}

Jump to

Keyboard shortcuts

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