upload()
Overload 1 of 2
Usenhost.storage.upload to upload a file.
It’s possible to use File or FormData to upload a file. The File instance is only available in the browser while FormData with form-data works both in the browser and in NodeJS (server).
If no bucketId is specified the bucket default is used.
Parameters
params required
StorageUploadFileParams
| Property | Type | Required | Notes |
|---|---|---|---|
| params.file | File | ✔️ | |
| params.bucketId | string | ||
| params.name | string | ||
| params.id | string | ||
| params.headers | Record<string, string> |
Examples
Upload a file from a browser usingFile.
File to a specific Bucket.
FormData with form-data.
Overload 2 of 2
Parameters
params required
StorageUploadFormDataParams
| Property | Type | Required | Notes |
|---|---|---|---|
| params.formData | FormData | FormData | ✔️ | |
| params.bucketId | string | ||
| params.headers | Record<string, string> |