createSignedUrl method
Create signed URL to download file without requiring permissions. This URL can be valid for a set number of seconds.
path
is the file path to be downloaded, including the current file
names. For example: createdSignedUrl('folder/image.png')
.
expiresIn
is the number of seconds until the signed URL expire. For
example, 60
for a URL which are valid for one minute.
transform
adds image transformations parameters to the generated url.
Implementation
Future<String> createSignedUrl(
String path,
int expiresIn, {
TransformOptions? transform,
}) async {
final finalPath = _getFinalPath(path);
final options = FetchOptions(headers: headers);
final response = await storageFetch.post(
'$url/object/sign/$finalPath',
{
'expiresIn': expiresIn,
if (transform != null) 'transform': transform.toQueryParams,
},
options: options,
);
final signedUrlPath = (response as Map<String, dynamic>)['signedURL'];
final signedUrl = '$url$signedUrlPath';
return signedUrl;
}