Documentation ¶
Index ¶
- Constants
- type DeleteFileResponse
- type ListFilesOpts
- type PresignedUrlOpts
- type PresignedUrlResponse
- type RenameFilesOpts
- type SingleFileRename
- type UploadthingFileResponse
- type UploadthingUrl
- type UploadthingUrlsResponse
- type UploadthingUsageInfo
- type UtApi
- func (ut *UtApi) DeleteFiles(fileKeys []string) (*DeleteFileResponse, error)
- func (ut *UtApi) GetFileUrls(fileKeys []string) (*UploadthingUrlsResponse, error)
- func (ut *UtApi) GetPresignedUrl(opts PresignedUrlOpts) (string, error)
- func (ut *UtApi) GetUsageInfo() (*UploadthingUsageInfo, error)
- func (ut *UtApi) ListFiles(opts ListFilesOpts) (*UploadthingFileResponse, error)
- func (ut *UtApi) RenameFiles(files RenameFilesOpts) error
Constants ¶
const ( DeletionPending uploadthingFileStatus = iota Failed Uploaded Uploading )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeleteFileResponse ¶
type DeleteFileResponse struct {
Success bool `json:"success"`
}
Full response object for a delete file action
type ListFilesOpts ¶
Arguments for the list files endpoint
type PresignedUrlOpts ¶
Arguments for the presigned url endpoint
type PresignedUrlResponse ¶
type PresignedUrlResponse struct {
Url string `json:"url"`
}
Represents a full response struct for a presigned url
type RenameFilesOpts ¶
type RenameFilesOpts struct {
Updates []SingleFileRename `json:"updates"`
}
Arguments for the rename files endpoint
type SingleFileRename ¶
type UploadthingFileResponse ¶
type UploadthingFileResponse struct {
Files []uploadthingFile `json:"files"`
}
Represents a full response struct for a list of files
type UploadthingUrl ¶
Represents a single uploadthing url
type UploadthingUrlsResponse ¶
type UploadthingUrlsResponse struct {
Data []UploadthingUrl `json:"data"`
}
Represents a full response struct for a list of urls
type UploadthingUsageInfo ¶
type UploadthingUsageInfo struct { TotalBytes int `json:"totalBytes"` TotalReadable string `json:"totalReadable"` AppTotalBytes float32 `json:"appTotalBytes"` AppTotalReadable string `json:"appTotalReadable"` FilesUploaded int `json:"filesUploaded"` LimitBytes float32 `json:"limitBytes"` LimitReadable string `json:"limitReadable"` }
Represents a full response struct for uploadthing usage info
func (*UploadthingUsageInfo) AsString ¶
func (u *UploadthingUsageInfo) AsString() string
type UtApi ¶
type UtApi struct {
// contains filtered or unexported fields
}
UtApi - Interact with the uploadthing api. This struct is designed to replicate UTApi from the uploadthing typescript sdk. Please note that responses are encoded into structs that mirror the current json. Any errors are returned as-is.
func NewUtApi ¶
Construct an instance of the UtApi struct. This will read the UPLOADTHING_SECRET environment variable from the .env file. If you don't have UPLOADTHING_SECRET set, the function will throw.
func (*UtApi) DeleteFiles ¶
func (ut *UtApi) DeleteFiles(fileKeys []string) (*DeleteFileResponse, error)
Delete files from uploadthing.
func (*UtApi) GetFileUrls ¶
func (ut *UtApi) GetFileUrls(fileKeys []string) (*UploadthingUrlsResponse, error)
Given an array of file keys, get the corresponding urls.
func (*UtApi) GetPresignedUrl ¶
func (ut *UtApi) GetPresignedUrl(opts PresignedUrlOpts) (string, error)
Generate a presigned url for a file. expiresIn should be a duration in seconds. The maximum value for expiresIn is 604800 (7 days). You must accept overrides on the UploadThing dashboard for expiresIn to be accepted.
func (*UtApi) GetUsageInfo ¶
func (ut *UtApi) GetUsageInfo() (*UploadthingUsageInfo, error)
Get usage info for the current uploadthing account.
func (*UtApi) ListFiles ¶
func (ut *UtApi) ListFiles(opts ListFilesOpts) (*UploadthingFileResponse, error)
List files stored in uploadthing.
func (*UtApi) RenameFiles ¶
func (ut *UtApi) RenameFiles(files RenameFilesOpts) error
Rename files in uploadthing. No response is returned, but an error is returned if the request fails. This is in line with the behaviour of the uploadthing typescript sdk.