Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

S3 upload: 'unique_names: true' doesn't work #254

Closed
ramonv opened this Issue Apr 4, 2011 · 5 comments

Comments

Projects
None yet
5 participants

ramonv commented Apr 4, 2011

If you add 'unique_names: true' to the S3 example, files are uploaded to Amazon S3 with the original filename instead of the unique filename.

This worked for me

BeforeUpload : function(up,file){
var file_name = file.name;
var extension = file_name.split(".").pop();
up.settings.multipart_params.key = up.id+"."+extension;
up.settings.multipart_params.Filename = up.id+"."+extension;
},

Basically override the key and filename with the id of the upload and adding the file extension ,.

huyl commented Apr 17, 2012

Same problem here.

@gafitescu thanks for the solution

(I had to be careful about overwriting the key there, though, because in a subdirectory)

@gafitescu's code didn't quite work for me. I ended up with:

BeforeUpload: function(up, file) {
    var file_name = file.name;
    var extension = file.name.split('.').pop();
    up.settings.multipart_params.key = this.task.get('id') +'/'+ file.id +'.'+ extension;
    up.settings.multipart_params.Filename = this.task.get('id') +'/'+ file.id +'.'+ extension;
}
Owner

jayarjo commented Nov 24, 2016

This is related: #785

Owner

jayarjo commented Nov 24, 2016

As in the case with rename option new file name is sent as separate param and handled by our upload.php. Obviously in the case of S3 there is nothing on Amazon Side to handle custom params, so one basically has to set it manually in the config.

@jayarjo jayarjo closed this Nov 24, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment