presignedUrl method

Future<String> presignedUrl(
  1. String method,
  2. String bucket,
  3. String object, {
  4. int? expires,
  5. String? resource,
  6. Map<String, String>? reqParams,
  7. DateTime? requestDate,
})

Generate a generic presigned URL which can be used for HTTP methods GET, PUT, HEAD and DELETE

  • method: name of the HTTP method
  • bucketName: name of the bucket
  • objectName: name of the object
  • expires: expiry in seconds (optional, default 7 days)
  • reqParams: request parameters (optional)
  • requestDate: A date object, the url will be issued at (optional)

Implementation

Future<String> presignedUrl(
  String method,
  String bucket,
  String object, {
  int? expires,
  String? resource,
  Map<String, String>? reqParams,
  DateTime? requestDate,
}) async {
  MinioInvalidBucketNameError.check(bucket);
  MinioInvalidObjectNameError.check(object);

  if (expires != null && expires < 0) {
    throw MinioInvalidArgumentError('invalid expire time value: $expires');
  }

  expires ??= 24 * 60 * 60 * 7; // 7 days in seconds
  reqParams ??= {};
  requestDate ??= DateTime.now().toUtc();

  final region = await getBucketRegion(bucket);
  final request = _client.getBaseRequest(
    method,
    bucket,
    object,
    region,
    resource,
    reqParams,
    {},
    null,
  );
  return presignSignatureV4(this, request, region, requestDate, expires);
}