How to use S3 Bucket getObjectTorrent with node js?

0

Hi i m using node js sdk with serverless aws lambda to getObjectTorrent for object inside s3 bucket but it gives me error "message": "The specified method is not allowed against this resource.",

Request: { "Bucket": "my-bucket-name", "Key": "file name with extension", "ExpectedBucketOwner": "my-account-id", "RequestPayer": "requester" }

 let s3 = new AWS.S3({
      region: " us-east-1",
      endpoint: 'https://s3.amazonaws.com/',
      // endpoint: 'https://lock-bucket.s3.amazonaws.com/request.PNG?torrent',
      accessKeyId: `${event.queryStringParameters.AccessKeyID}`,
      secretAccessKey: `${event.queryStringParameters.SecretAccessKey}`,
    });

    

    let params: AWS.S3.GetObjectTorrentRequest = {
      Bucket: event.body.Bucket,
    //  Key: `${event.body.Key}`,
      Key: event.body.Key,
      ExpectedBucketOwner: event.body.ExpectedBucketOwner,
      RequestPayer: event.body.RequestPayer,
    };
    console.log(params);

    let data = await s3.getObjectTorrent(params).promise();
    return formatJSONResponse(
      {
        data,
      },
      200
    );

Error Message: "message": "Internal server", "error": { "message": "The specified method is not allowed against this resource.", "code": "MethodNotAllowed", "region": null, "time": "2022-02-03T09:53:50.202Z", "requestId": "9KMFF5C74NPN1BHY", "extendedRequestId": "Jpog5Y5godEIJP8+9EJlv+VbCz8QK8UewsR8f/fH7039KrSBTDjcG1SyGhkdocUd8e+VhrXQVgk=", "statusCode": 405, "retryable": false, "retryDelay": 8.720824387981164 }

2 Answers
0

Also, "RequestPayer": "2requester" - 2 is a typo here or you really have 2 there? Valid value is requester

answered 2 years ago
  • A-Shevchenko "RequestPayer " is an optional parameter

  • well, yes, but in your example it's passed and had a wrong value (now corrected)

0

There are some limitations on that operation ( https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectTorrent.html )

You can get torrent only for objects that are less than 5 GB in size, and that are not encrypted using server-side encryption with a customer-provided encryption key.

So probably you're facing them

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions