0

In my website, users are uploading audio files. I wish to convert all supported audio files to MP3.

I prefered to make the convertion in the filefield_clean function because in that moment I am also able to confirm that the file format uploaded is supported. In addition I am using S3 so it just before to file is uploaded to my S3 Storage.

My problem is how can I redirect the physical file used in the InMemoryUploadedFile ? I need to redirect it to my new converted file.

Is it possible to accomplish this in a clean operation ? If not, what is the best approch ?

Nuno_147
  • 2,817
  • 5
  • 23
  • 36
  • Create a link to the mp3, but have a batch job asynchronously convert it. Don't do it on the fly in the FileField if you want to have some form of performance left in your application. – Henrik Andersson Sep 25 '13 at 20:56
  • Audio files are very small so it isn't a big issue to convert it on the fly. Even that I am well aware of it. Still. cant figure out how to accomplish what I refered to. – Nuno_147 Sep 25 '13 at 20:58
  • What do you mean `redirect the physical file`? You mean how do you upload the .mp3 to S3? – Henrik Andersson Sep 25 '13 at 21:04
  • I would like to my form will be pointing to the new converted mp3 file instead of the original uploaded files so when I save the form (It is a modalForm) the new file will gets uploaded instead of the original one. – Nuno_147 Sep 25 '13 at 21:07
  • Okay, here you go then http://stackoverflow.com/questions/2680391/in-django-changing-the-file-name-of-uploading-file – Henrik Andersson Sep 25 '13 at 21:20

0 Answers0