4

I have dropzone set-up and working with my AWS S3 account. However I want to be able to rename the file before it is sent to S3 (append with timestamp for example) so that a file uploaded with the same name as an existing file will not get overwritten. I've tried to catch this at the sending event and to update the file name at this point but without success:

this.on("sending", function(file) {
  file.name = 'my-new-prefix-' + file.name;
});

Any ideas where I am going wrong or why this isn't working?

Also have raised this earlier at - https://github.com/enyo/dropzone/issues/345

Adrian Walls
  • 852
  • 3
  • 19
  • 31

1 Answers1

5

I currently use FromData() - Dropzone.js which allows you to send custom data.

// with options.params = true;

this.on("sending", function(file) {
  formData.append("custom", "my-new-prefix-" + file.name);
});

I know this is not exactly what is your question, it is only a temporary solution without modifying the source code

You can also pass object directly in options:

el.dropzone({
  params: {
    data: "data"
  }
});
Pierre Broucz
  • 687
  • 5
  • 8
  • Maybe I am missing something but how does this update the file name getting posted to S3? – Adrian Walls Oct 17 '13 at 19:42
  • During your image process before upload to S3, you can handle custom params and so rename your file – Pierre Broucz Oct 18 '13 at 08:04
  • Just got back to look at this and this works perfect. Cheers. – Adrian Walls Oct 24 '13 at 14:22
  • @PierreBroucz Can you please tell me in detail how to change file name before uploading using with dropzone.js. Check my question: http://stackoverflow.com/q/24859005/3113858 – Mr.Happy Jul 21 '14 at 08:53
  • @PierreBroucz Can you elaborate that `params` one as I want to use that instead of `formData` because that gives `undefined` error. – Volatil3 Jan 04 '16 at 10:07