getObjectTorrent method

Future<GetObjectTorrentOutput> getObjectTorrent({
  1. required String bucket,
  2. required String key,
  3. String? expectedBucketOwner,
  4. RequestPayer? requestPayer,
})

Returns torrent files from a bucket. BitTorrent can save you bandwidth when you're distributing large files. For more information about BitTorrent, see Using BitTorrent with Amazon S3. To use GET, you must have READ access to the object.

This action is not supported by Amazon S3 on Outposts.

The following operation is related to GetObjectTorrent:

Parameter bucket : The name of the bucket containing the object for which to get the torrent files.

Parameter key : The object key for which to get the information.

Parameter expectedBucketOwner : The account id of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error.

Implementation

Future<GetObjectTorrentOutput> getObjectTorrent({
  required String bucket,
  required String key,
  String? expectedBucketOwner,
  RequestPayer? requestPayer,
}) async {
  ArgumentError.checkNotNull(bucket, 'bucket');
  ArgumentError.checkNotNull(key, 'key');
  _s.validateStringLength(
    'key',
    key,
    1,
    1152921504606846976,
    isRequired: true,
  );
  final headers = <String, String>{
    if (expectedBucketOwner != null)
      'x-amz-expected-bucket-owner': expectedBucketOwner.toString(),
    if (requestPayer != null) 'x-amz-request-payer': requestPayer.toValue(),
  };
  final $result = await _protocol.sendRaw(
    method: 'GET',
    requestUri:
        '/${Uri.encodeComponent(bucket)}/${key.split('/').map(Uri.encodeComponent).join('/')}?torrent',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return GetObjectTorrentOutput(
    body: await $result.stream.toBytes(),
    requestCharged: _s
        .extractHeaderStringValue($result.headers, 'x-amz-request-charged')
        ?.toRequestCharged(),
  );
}