Dart Reference v2.0

Replace an existing file

Replaces an existing file at the specified path with a new one.

  • Policy permissions required:
    • buckets permissions: none
    • objects permissions: update and select
  • 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/local/file');
final String path = await supabase.storage.from('avatars').update(
      'public/avatar1.png',
      avatarFile,
      fileOptions: const FileOptions(cacheControl: '3600', upsert: false),
    );