django芹菜 - 如何发送request.FILES ['照片']到任务 [英] django celery - how to send request.FILES['photo'] to task

查看:104
本文介绍了django芹菜 - 如何发送request.FILES ['照片']到任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过以下方式发送request.FILES ['photo'],一个上传的文件到tCelery:

i'm trying to send request.FILES['photo'], an uploaded file from my site, to tCelery via:

tasks.upload_photos.delay(img=request.FILES['photo'])

I得到一个pickle错误,因为它不能序列化它。发送文件到任务的方式是什么?

I get a pickle error because it cannot serialize it. What is the way to send a file to task?

错误:无法打开StringO对象
谢谢。

error: "can't pickle StringO objects" thanks.

推荐答案

将文件内容读入字符串,然后用dict中的内容类型打包,然后发送。

Read the file contents into a string, then pack it with the content type in a dict and send that.

这篇关于django芹菜 - 如何发送request.FILES ['照片']到任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆