Topic: unique_names and Amazon S3

Hi,

I have Plupload up and running with Amazon S3. Now I need to make sure that the files I upload are uniquely named or they will conflict with the existing ones. I thought that "unique_names" would do that, but nothing happens when I set it to true. Am I missing something here or will unique_names not work with S3?

Re: unique_names and Amazon S3

Any luck here?

I need something like this otherwise maybe I'll have to reinitialize the uploader with params each time generated by the server via an AJAX request and disable multiple file upload. I guess you could key each folder uniquely too each time and depend on the user not to upload the same filename twice too but that doesn't seem great.

Re: unique_names and Amazon S3

Hi,

I am afraid I never did find a solution to the problem.

Re: unique_names and Amazon S3

I figured it out! unique_names will pass another name param with a new name but S3 and Google Storage ignore that - I give an overview of that finding here: http://www.plupload.com/punbb/viewtopic.php?pid=4306

The solution is to use the key param to set the filename manually for each file. Do this in the UploadFile event where you can change the params for each file that's uploaded on the fly. It would look something like this:

$(function() {
    $("#uploader").plupload({
        // PreInit events, bound before any internal events
        preinit : {

            UploadFile: function(up, file) {
                up.settings.multipart_params.key = 'plupload/blah'+randomString()+'.jpg';

                // You can override settings before the file is uploaded
                // up.settings.url = 'upload.php?id=' + file.id;
                // up.settings.multipart_params = {param1 : 'value1', param2 : 'value2'};
            }
        },
......

Hope that helps people!