开发者

POSTing JPG|PNG along with JSON description with django-piston

I'm defining a create() method in d开发者_如何学Gojango-piston. I need to be able to receive and image with its description enconded in JSON. How to do it? Shall they be processed in two separate HTTP requests?


I'd suggest posting your file as a multi-part encoded form just like your web browser does when you upload a file through a form. With multi-part encoding you can send the file as binary data element in your form (much better than BASE64 encoding your JPG in JSON), and then another element that holds your JSON data. It's one request. There are plenty of libraries out there that parse things in this form so it's easy to do.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜