setObjectAcl method

Future<bool> setObjectAcl(
  1. String key,
  2. S3Acl acl
)

Applies a canned ACL to an existing object.

This sends a PUT request with the acl query parameter and x-amz-acl header.

Returns true when S3 responds with 200 OK.

Example:

final updated = await client.setObjectAcl(
  'uploads/avatar.png',
  S3Acl.publicRead,
);
print(updated);

Implementation

Future<bool> setObjectAcl(String key, S3Acl acl) async {
  try {
    final response = await _makeRequest(method: 'PUT', path: key, queryParams: {'acl': ''}, extraHeaders: {'x-amz-acl': acl.value});

    return response.statusCode == 200;
  } catch (e) {
    return false;
  }
}