uploadToSignedUrl method
Future<String>
uploadToSignedUrl(
- String path,
- String token,
- File file, [
- FileOptions fileOptions = const FileOptions(),
- int? retryAttempts,
- StorageRetryController? retryController,
Upload a file with a token generated from createUploadSignedUrl.
path 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.
token The token generated from createUploadSignedUrl
file The body of the file to be stored in the bucket.
Implementation
Future<String> uploadToSignedUrl(
String path,
String token,
File file, [
FileOptions fileOptions = const FileOptions(),
int? retryAttempts,
StorageRetryController? retryController,
]) async {
_assertValidRetryAttempts(retryAttempts);
final cleanPath = _removeEmptyFolders(path);
final finalPath = _getFinalPath(cleanPath);
var requestUrl = Uri.parse('$url/object/upload/sign/$finalPath');
requestUrl = requestUrl.replace(queryParameters: {'token': token});
await _storageFetch.putFile(
requestUrl.toString(),
file,
fileOptions,
retryAttempts: retryAttempts ?? _retryAttempts,
retryController: retryController,
);
return cleanPath;
}