Closed dotfury closed 10 years ago
@dotfury Can you pls. point me to the documentation, to set bucketUrl
as part of the request payload?
@arvindr21 I don't think it is in the documentation. It's more of a hack right now just to get a usable url on the uploaded objects and prevent the amazon redirect error. I just called it bucketUrl because I couldn't think of a better name. I'll look through the docs and see if I can find anything more solid.
@dotfury Sure. Thanks. There was a redirect issue similar to this earlier, but at that point setting the bucket location solved the issue. Can you try that too?
Found this answer in the AWS forums from 2012. https://forums.aws.amazon.com/thread.jspa?threadID=93828
"The following patterns are valid for constructing S3 URLs:
http(s)://
Because the pattern is so simple, we've never added a get_bucket_url() method."
So it may need to be constructed manually.
Yup, we follow the second approach from the links below
http(s)://<bucket>.s3.amazonaws.com/<object>
http(s)://s3.amazonaws.com/<bucket>/<object>
i.e.
sss = {url : (options.useSSL ? 'https:' : 'http:')+'//s3.amazonaws.com/'+options.storage.aws.bucketName+'/'+o.Key }
Is it still causing an issue?
Yes, got redirect errors. So I used the first one, which fixed it for me.
http(s)://[bucket].s3.amazonaws.com/[object]
Okay, so do you think exposing this an option will help?
I think it will, not sure why the first one you had didn't work for me, so others may run into the same issue.
Okay, will add this as an option soon. Thanks!
Awesome. Thanks!
The automatically generated urls cause a permanent redirect error when trying to access them (in an tag, etc.).
"The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint."
Added bucketUrl to the objects with the proper endpoint, which seems to work.
Edited source code of the node module on my local as follows:
sss = {url : (options.useSSL ? 'https:' : 'http:')+'//s3.amazonaws.com/'+options.storage.aws.bucketName+'/'+o.Key, bucketUrl: (options.useSSL ? 'https:' : 'http:') +'//'+options.storage.aws.bucketName + '.s3.amazonaws.com/' + o.Key }
This produced an accessible url.