开发者

Save raw_post_data to FileField using Django

I need to save some Raw Post Data (request.raw_post_data) straight to a FileField using Python/Django. All the information I have found so far is not helpful for saving RAW data.

More specifically, the raw data is the wave data recorded from a Mic using Flash.

Can someone please show me how this is done开发者_开发百科?

Thanks!


Ok. I figured it out. You can use SimpleUploadedFile like this:

if request.method == 'POST':
    from django.core.files.uploadedfile import SimpleUploadedFile
    object = Model.objects.get(pk=1)
    file_contents = SimpleUploadedFile("%s.mp3" % "myfile", request.raw_post_data, "audio/mp3")
    object.audio.save("%s.mp3" % "myfile", upfile, True)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜