Skip to content

Go V1 SDK, possible to add custom HTTP headers to PutObject? #4703

Answered by aajtodd
Schachte asked this question in Q&A
Discussion options

You must be logged in to vote

Based on the code sample I'm assuming you are trying to do this with s3manager.Uploader?

You can set request options either on the uploader (which will apply to all requests) or for a specific request.

Apply to all requests from uploader:

uploader := s3manager.NewUploader(sess, func(u *s3manager.Uploader) {
	u.RequestOptions = append(u.RequestOptions, func(request *request.Request) {
		request.HTTPRequest.Header.Add("my-header", "value")
	})
})

Apply to a specific request:

uploader.Upload(input, func(u *s3manager.Uploader) {
	u.RequestOptions = append(u.RequestOptions, func(request *request.Request) {
		request.HTTPRequest.Header.Add("my-header", "value")
	})
})

The same pattern is used …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Schachte
Comment options

Answer selected by Schachte
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants