Dart Reference v2.0

Upload a file

Uploads a file to an existing bucket.

  • Policy permissions required:
    • buckets permissions: none
    • objects permissions: insert
  • Refer to the Storage guide on how access control works
Parameters
    path
    REQUIRED
    String

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

    file
    REQUIRED
    File or Uint8List

    File object to be stored in the bucket.

    fileOptions
    Optional
    FileOptions
    retryAttempts
    Optional
    int

    Sets the retryAttempts parameter set across the storage client. Defaults to 10.

    retryController
    Optional
    StorageRetryController

    Pass a RetryController instance and call cancel() to cancel the retry attempts.


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