This is just a thought, but you could separate the file encoding and
storage from your model and hand that off to a Celery task.

Off the top of my head:
- use a "file path" charfield and a "is ready" boolean field in your
model
- use a FileField in your form
- when the form/upload are validated, save the model as normal with
the expected path of the file
- add the encode/store task to celery
- once encoding is complete, move the file to S3 and update the "is
ready" field on the model

I'm sure there are nuances that I'm missing (how would this work with
in-memory files?), but that's the gist.

One thing: encoding is always CPU intensive, so I'd queue it even if I
was  planning on storing locally. If you can afford to pass the
encoding off to another server entirely, that would be even better.
Here's an example of a video encoding server designed to run in Amazon
EC2: http://pandastream.org/

V

On Aug 11, 10:32 pm, Braddikins <percy...@gmail.com> wrote:
> Hello,
>
> I wish the user to be able to upload an MP3, WAVE, or AIFF file via
> POST.
> If the file is a WAVE or AIFF file, it is encoded to an MP3 by the
> server first.
>
> At the moment I have a model with a FileField to store the sound file.
> I am testing it through the admin interface. I have Python libraries
> to encode MP3s and to validate whether a file is an MP3, WAVE, or
> AIFF, so that side of things is taken care of.
>
> I am stuck on where and how to best implement this. The problem is I
> am using Amazon's S3 storage, so I would like to be able to swap the
> WAVE or AIFF to the generated MP3 after the POST file data is
> received, but before the file is uploaded via Django's storage system.
> I would like the conversion to happen as seamlessly as possible... can
> I implement this conversion somehow in the model, or do I need to use
> a form? Or some other method? It gets a bit complicated as the POST
> file can be in memory or on disk, depending on its size.
>
> Any advice would be appreciated, thanks for reading.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to