presign method
void
presign(
- AWSRequest request, {
- Duration expires = const Duration(seconds: 60),
- bool? signPayload,
- DateTime? overrideDate,
Presigns the given request by adding the signature to the URL.
Time period, for which the generated presigned URL is valid
is specified with expires
. Minimum value is 1 second and
maximum is 7 days.
Signing date can be overriden with overrideDate
.
Signing payload can be disabled by setting signPayload
to false
.
It's enabled by default for all services except s3
, unless implicitly
overriden.
IMPORTANT: Only GET requests can be presigned. In order to presign POST request with form-encoded body, it must be first transformed into the corresponding GET request (by moving body to query string).
Implementation
void presign(
AWSRequest request, {
Duration expires = const Duration(seconds: 60),
bool? signPayload,
DateTime? overrideDate,
}) {
assert(request.method == 'GET');
assert(expires >= Duration(seconds: 1));
assert(expires <= Duration(days: 7));
signPayload ??= _shouldSignPayload(serviceName);
_sign(request, overrideDate, expires, signPayload);
}