Upload a file
Uploads a file to an existing bucket.
- Policy permissions required:
buckets
permissions: noneobjects
permissions:insert
- Refer to the Storage guide on how access control works
Parameters
The relative file path. Should be of the format folder/subfolder/filename.png. The bucket must already exist before attempting to update.
File object to be stored in the bucket.
The number of seconds the asset is cached in the browser and in the Supabase CDN. This is set in the `Cache-Control` header as `max-age=<seconds>`. Defaults to 3600 seconds.
When upsert is set to true, the file is overwritten if it exists. When set to false, an error is thrown if the object already exists. Defaults to false.
The `Content-Type` header value. Gets parsed with MediaType.parse(mime). Throws a FormatError if the media type is invalid.
Sets the retryAttempts parameter set across the storage client. Defaults to 10.
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),
);