Jack
Jack

Reputation: 446

Having problems with Image File POST to Django Server through API

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!

Upvotes: 0

Views: 340

Answers (2)

Jack
Jack

Reputation: 446

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

Upvotes: 0

Saransh Mohapatra
Saransh Mohapatra

Reputation: 9636

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?

Upvotes: 1

Related Questions