getObject method

Future<Uint8List?> getObject(
  1. String key
)

Downloads an object as raw bytes.

Returns the object body when the request succeeds with 200, otherwise returns null.

Example:

final bytes = await client.getObject('uploads/avatar.png');
print(bytes?.length);

Implementation

Future<Uint8List?> getObject(String key) async {
  try {
    final response = await _makeRequest(method: 'GET', path: key);

    return response.statusCode == 200 ? response.body : null;
  } catch (e) {
    return null;
  }
}