Aws-sdk-js: S3 putObject, custom headers

Created on 10 Sep 2013  路  3Comments  路  Source: aws/aws-sdk-js

Hi,

Is it possible to pass custom headers (for object) with putObject method?
Custom headers should not start with x-amz-

guidance

Most helpful comment

Can you explain a little more about what you are trying to achieve? If your goal is to pass custom headers that are stored with your object, you can use the Metadata argument on putObject(). For example:

s3 = new AWS.S3({params: {Bucket: 'mybucket', Key: 'mykey'}});
s3.putObject({Metadata: {customfield: 'customvalue'}}, function (err, data) { ... });

If you are simply trying to pass extra headers along with the request, you can build them up on the request object yourself like so:

var req = s3.putObject(params);
req.httpRequest.headers['Custom-Header'] = 'custom-value';
req.send(function (err, data) { console.log(data) });

Does this answer your question?

All 3 comments

Can you explain a little more about what you are trying to achieve? If your goal is to pass custom headers that are stored with your object, you can use the Metadata argument on putObject(). For example:

s3 = new AWS.S3({params: {Bucket: 'mybucket', Key: 'mykey'}});
s3.putObject({Metadata: {customfield: 'customvalue'}}, function (err, data) { ... });

If you are simply trying to pass extra headers along with the request, you can build them up on the request object yourself like so:

var req = s3.putObject(params);
req.httpRequest.headers['Custom-Header'] = 'custom-value';
req.send(function (err, data) { console.log(data) });

Does this answer your question?

Closing this stale issue. Feel free to comment or open another issue if you still have other questions.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings