Skip to main content
Version: v0

from.upload()

Uploads a file to an existing bucket.

final avatarFile = File('path/to/file');
final res = await supabase
.storage
.from('avatars')
.upload('public/avatar1.png', avatarFile, fileOptions: FileOptions(
cacheControl: '3600',
upsert: false
));

Parameters

  • pathrequiredstring

    The relative file path. Should be of the format folder/subfolder/filename.png. The bucket must already exist before attempting to upload.

  • fileBodyrequiredArrayBuffer | ArrayBufferView | Blob | Buffer | File | FormData | ReadableStream | ReadableStream | URLSearchParams | string

    The body of the file to be stored in the bucket.

      Properties
    • URLSearchParamsrequiredobject

      No description provided.

    • stringrequiredobject

      No description provided.

    • ReadableStreamrequiredobject

      No description provided.

    • ReadableStreamrequiredobject

      No description provided.

    • FormDatarequiredobject

      No description provided.

    • Filerequiredobject

      No description provided.

    • Bufferrequiredobject

      No description provided.

    • Blobrequiredobject

      No description provided.

    • ArrayBufferViewrequiredobject

      No description provided.

    • ArrayBufferrequiredobject

      No description provided.

  • fileOptionsoptionalFileOptions

    HTTP headers. cacheControl: string, the Cache-Control: max-age=<seconds> seconds value. contentType: string, the Content-Type header value. Should be specified if using a fileBody that is neither Blob nor File nor FormData, otherwise will default to text/plain;charset=UTF-8. upsert: boolean, whether to perform an upsert.

Notes

  • Policy permissions required:
    • buckets permissions: none
    • objects permissions: insert

Examples

Upload file

final avatarFile = File('path/to/file');
final res = await supabase
.storage
.from('avatars')
.upload('public/avatar1.png', avatarFile, fileOptions: FileOptions(
cacheControl: '3600',
upsert: false
));