0

I've spent all day trying to get this Imagefile POST working to no avail. I would be extremely grateful if anyone could provide a little assistance to push me in the right direction! I am using Django Tastypie Restful API service.

Here is what I have so far in my attempt to POST an image to my server and save it - but I think I've gotten the whole spectrum of status errors from 404s to 500s. Would greatly appreciate any insight :) http://pastebin.com/7iXpDvkD

Thank you in advance!

Jack
  • 436
  • 2
  • 9
  • 23

2 Answers2

1

Don't try to post an image in Tastypie JSON format. Upload it using a multi-part form data in plain Django. I am saying so not because you can't do, but coz its difficult and not the right approach also. Secondly it increases the uploaded file-size 30%-40% which might be a problem to most people.

Still I leave it to you decide what to do and I am putting links for file uploading using Django and Tastypie both. Make your choice.

Plain django - https://docs.djangoproject.com/en/dev/topics/http/file-uploads/ This is straight from Django docs and mostly sufficient for any basic needs.

Using Tastypie- Django-tastypie: Any example on file upload in POST? How do you upload a file with a POST request on django-tastypie?

Community
  • 1
  • 1
Saransh Mohapatra
  • 9,430
  • 10
  • 39
  • 50
  • Thank you for the response. I did see the two tastypie links in my search and was a little confused and I feel like I'm blanking - This may be a simple question, but would you know off hand how I save the image through tastypie after doing something similar to the code here: http://stackoverflow.com/a/14134853/1493591 or is the POST satisfactory in doing that? Thank you! – Jack Jun 07 '13 at 02:07
0

I figured out the solution to my issue which was a faulty curl command in the file directory.

Jack
  • 436
  • 2
  • 9
  • 23