Dart Reference v1.0

Upload a file

Uploads a file to an existing bucket.

Uploads a file to an existing bucket.

  • Policy permissions required:
    • buckets permissions: none
    • objects permissions: insert
Parameters
    path
    REQUIRED
    string

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

    fileBody
    REQUIRED
    FileBody

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

    fileOptions
    Optional
    FileOptions

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