header method

  1. @override
Map<String, String>? header({
  1. String? path,
})
override

Generates the header map used within the GET request.

Assumes that the user's auth AWS credentials

Implementation

@override
Map<String, String>? header({
  String? path,
}) {
  if (!(path != null && path.isNotEmpty)) {
    throw new AssertionError('The path to the OAS spec should be provided');
  }

  // Use the provided credentials to the constructor, if any, otherwise
  // fallback to the environment values or throw.
  final accessKey = accessKeyId ?? Platform.environment['AWS_ACCESS_KEY_ID'];
  final secretKey =
      secretAccessKey ?? Platform.environment['AWS_SECRET_ACCESS_KEY'];
  if ((accessKey == null || accessKey.isEmpty) ||
      (secretKey == null || secretKey.isEmpty)) {
    throw new AssertionError(
        'AWS_SECRET_KEY_ID & AWS_SECRET_ACCESS_KEY should be defined and not empty or they should be provided in the delegate constructor.');
  }

  final now = DateTime.now();

  return {
    'Authorization': authHeaderContent(
      now: now,
      bucket: bucket,
      path: path,
      accessKeyId: accessKey,
      secretAccessKey: secretKey,
    ),
    'x-amz-date': now.toIso8601String(),
  };
}