Quick question about changing the filename when uploading to S3

Archived from the Transloadit support forum. Originally posted on August 8, 2012; details may be outdated, see our docs for current behavior. Original thread

Quick question about changing the filename when uploading to S3…

I set a hidden variable in my form called “fileprefix” to some special prefix text as I do not want to use your 33 digit unique prefix when uploading to S3:

Which turns into something like the following:

In my template, in the store section, I also set the path variable option to:

“path”: “${fields.fileprefix}${file.url_name}”

I also tried this variation:

“path”: “${fields.fileprefix}”

But, it is not working, so i must be doing something wrong. The point is just to add a string prefix to the start of the filename and have them all in the same folder. Your 33 digit string goes 2 folder levels deep, but that is a pain, I just want a simple numbering strategy with all my uploads in the top level S3 bucket.

So, the question is what is the correct syntax for simply adding a string prefix to the title of the uploaded file when it gets saved to S3? I assume the path variable is the proper place in the template to store that data, but perhaps that is not really clear as I am not even sure if I am supposed to add the url_name on it or not. Can’t find the answer in your documentation.

Thanks, I just want to be able to organize my bucket the way I want to see it.

Ben Cahan

Hey Ben,

the syntax is correct. Please make sure you pass

fields: true

as an option to the jQuery plugin. Let me know if this helps.

Kind regards,
Tim

Tim,

Thanks, that worked perfectly. You can close this discussion, I guess I just did not see the fields parameter in the jQuery list among all the other fields there.

By the way, Transloadit is now fully implemented for audio and video at my site and so far is working perfectly and seamlessly. A real life saver that allows my users to upload audio and video in a wide variety of formats with the knowledge that we will convert it to something that we know we can display.

Ben Cahan

Awesome, closing this.