checksum method

  1. @override
Future<String?> checksum(
  1. String path, {
  2. String algorithm = 'md5',
})

Get the checksum for the given file.

Implementation

@override
Future<String?> checksum(String path, {String algorithm = 'md5'}) {
  return _attempt<String?>(null, () async {
    final object = await bucket.head(_objectKey(path));
    if (object == null) return null;
    final normalized = algorithm.toLowerCase().replaceAll('-', '');
    final checksum = object.checksums[normalized];
    if (checksum != null) return checksum;
    return normalized == 'md5' ? object.etag : null;
  });
}