arvindr21 / blueimp-file-upload-expressjs

A simple express module for integrating jQuery File Upload.
http://expressjs-fileupload.cloudno.de/
104 stars 69 forks source link

Generated url XML permanent redirect #16

Closed dotfury closed 10 years ago

dotfury commented 10 years ago

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.

arvindr21 commented 10 years ago

@dotfury Can you pls. point me to the documentation, to set bucketUrl as part of the request payload?

dotfury commented 10 years ago

@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.

arvindr21 commented 10 years ago

@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?

dotfury commented 10 years ago

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)://.s3.amazonaws.com/ http(s)://s3.amazonaws.com//

Because the pattern is so simple, we've never added a get_bucket_url() method."

So it may need to be constructed manually.

arvindr21 commented 10 years ago

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?

dotfury commented 10 years ago

Yes, got redirect errors. So I used the first one, which fixed it for me.

http(s)://[bucket].s3.amazonaws.com/[object]

arvindr21 commented 10 years ago

Okay, so do you think exposing this an option will help?

dotfury commented 10 years ago

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.

arvindr21 commented 10 years ago

Okay, will add this as an option soon. Thanks!

dotfury commented 10 years ago

Awesome. Thanks!