Ability to attach custom headers to S3 uploaded files

115 views
Skip to first unread message

Dusty Wilson

unread,
Apr 10, 2012, 9:56:54 PM4/10/12
to go...@googlegroups.com
Is there a way to PUT a file to S3 with some custom headers attached?  I need to set Content-Disposition and Access-Control-Allow-Origin for various files.  I notice that I could use S3.query() if it weren't private.  I just wanted to make sure that there wasn't something I was missing before I try to implement it myself.

Thanks!
Dusty

Keith Rarick

unread,
Jul 12, 2012, 3:16:46 AM7/12/12
to go...@googlegroups.com
I also need to set content-disposition.
Gustavo, would you accept a patch to
add support for custom headers?

How would you recommend going about
the implementation? How would you feel
if each of the Bucket methods (Put, Get,
Del, etc) returned a Request value rather
than actually running the operation? The
user could, optionally, add headers to the
request, then actually send it. So it'd be
something like this:

    err := b.NewPut(...).Do()

or, to set a header:

    r := b.NewPut(...)
    r.Header.Set("content-disposition", "...")
    err := r.Do()

kr

Gustavo Niemeyer

unread,
Jul 17, 2012, 2:18:33 PM7/17/12
to Keith Rarick, go...@googlegroups.com
Hey Keith,

On Thu, Jul 12, 2012 at 4:16 AM, Keith Rarick <k...@xph.us> wrote:
> I also need to set content-disposition.
> Gustavo, would you accept a patch to
> add support for custom headers?

Definitely. The only issue is that I'm not entirely sure about the
best approach around this yet. I've been thinking about this, and will
try to experiment with an interface to get a feeling for how it would
look like in practice.

> How would you recommend going about
> the implementation? How would you feel
> if each of the Bucket methods (Put, Get,
> Del, etc) returned a Request value rather
> than actually running the operation? The
> user could, optionally, add headers to the
> request, then actually send it. So it'd be
> something like this:
>
> err := b.NewPut(...).Do()
>
> or, to set a header:
>
> r := b.NewPut(...)
> r.Header.Set("content-disposition", "...")
> err := r.Do()

Yeah, I know this is how the Google APIs are structure, but I honestly
don't find these interfaces very attractive. It feels a bit like
foo.DoIt(foo).NoIMeanit().

Maybe that's the best way to go, though. Please give me a moment and
I'll try to come up with something this week still.


gustavo @ http://niemeyer.net

Walt Norblad

unread,
May 30, 2014, 9:40:19 PM5/30/14
to go...@googlegroups.com, k...@xph.us
Hey Guys,

I'd like to bump these ideas. I would like to supply custom headers, but i would also like to be able to change the request method.

Locally, I've changed the goamz/s3 project to make the Query() accessible from outside the package. I got the solution to work by exposing some extra types. I dislike hacking the code only for myself and I've tinkered with some alternatives to what I did, but think it would be good to talk options before I go too far. 

I could go for the GoogleAPI style if it were additional to the existing API. For example: NewRequest(...) (request Request). Then DoRequest(request)

Let me know if I can help or if this already got solved.

Thanks,
Walt

Dalton Caughell

unread,
Nov 6, 2014, 8:03:38 PM11/6/14
to go...@googlegroups.com, k...@xph.us
Hey,

I'd also like to bump this. It would be especially useful for specifying x-amz-server-side​-encryption​-customer-algorithm for server side encryption. Currently it dose not seem possible to upload with this value set.

Maybe just add a "additional headers" parameter to the s3 PUT methods?

jon.s...@ontariosystems.com

unread,
Oct 4, 2016, 10:13:39 AM10/4/16
to goamz, k...@xph.us
Is this being worked on or has been been fixed yet?
Reply all
Reply to author
Forward
0 new messages