update method

Future<String> update(
  1. String path,
  2. File file, {
  3. FileOptions fileOptions = const FileOptions(),
  4. int? retryAttempts,
  5. StorageRetryController? retryController,
})

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

path is the relative file path without the bucket ID. Should be of the format folder/subfolder/filename.png. The bucket must already exist before attempting to upload. file is the file object to be stored in the bucket.

fileOptions HTTP headers. For example cacheControl

retryAttempts overrides the retryAttempts parameter set across the storage client.

You can pass a retryController and call cancel() to cancel the retry attempts.

Implementation

Future<String> update(
  String path,
  File file, {
  FileOptions fileOptions = const FileOptions(),
  int? retryAttempts,
  StorageRetryController? retryController,
}) async {
  assert(retryAttempts == null || retryAttempts >= 0,
      'retryAttempts has to be greater or equal to 0');
  final finalPath = _getFinalPath(path);
  final response = await _storageFetch.putFile(
    '$url/object/$finalPath',
    file,
    fileOptions,
    options: FetchOptions(headers: headers),
    retryAttempts: retryAttempts ?? _retryAttempts,
    retryController: retryController,
  );

  return (response as Map<String, dynamic>)['Key'] as String;
}