Signed URL for uploading

29 views
Skip to first unread message

Bjorn Roche

unread,
Oct 22, 2013, 4:31:03 PM10/22/13
to go...@googlegroups.com
I'd like to be able to create a signed URL that can be used by someone else who has the URL, but not any other credentials, to upload to s3. I've done this before with the Java APIs.

I'm new to go, but it seems to me this is not currently supported. I think it would require a function something like the code below, but I don't recall the S3 API well enough to to know for sure. Ideally, it might also specify some other things like the maximum size of the upload and the content-type (I recall being able to specify these things, but I don't recall how).

Am I missing a feature somewhere where this can be done?

// SignedURL returns a signed URL that allows anyone holding the URL
// to retrieve or upload the object at path. The signature is valid until expires.
func (b *Bucket) SignedURL(path string, method string, expires time.Time) string {
	req := &request{
		bucket: b.Name,
		path:   path,
		params: url.Values{"Expires": {strconv.FormatInt(expires.Unix(), 10)},
			"Method": method }}
	}
	req.method = method
err := b.S3.prepare(req) if err != nil { panic(err) } u, err := req.url() if err != nil { panic(err) } return u.String() }
Reply all
Reply to author
Forward
0 new messages