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!
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?
I figured out the solution to my issue which was a faulty curl command in the file directory.
Related
I followed a course where I made a django app like this https://www.studybud.dev/ and always get error when trying to upload it, I don't even have a solid understanding on how to uplaod my django website. I watched lots of videos but all of them were poor as none of them worked.
Tried uploading it for more than a month but with no avail, I tried using heroku,python anywhere and many others but some of them required credit card info and others don't work.
I would appreciate any form of help.
I decided to learn such a technology as GraphQL. For this, I came up with an application (I develop it on ReactNative), a python backend (django-graphene). How the client chose Apollo. I set everything up, everything works, I even did a part already. And here I needed to upload a profile photo. The problem is that I haven't found a way to do this. I used to use the REST API and the client was axios. So I just took the FormData and passed it. Accordingly, the backend accepted and saved as usual. And here I don't even know where to start. I found the apollo-upload-client package, but I didn't find how to integrate it into ReactNative (more precisely, there is a description there, but I didn't understand how to use it correctly). I do it like this:
const fileSubstitute = {
uri: uriFromCameraRoll,
name: "a.jpg",
type: "image/jpeg",
};
I found graphene-file-upload for the backend, it seems to see my files, but I don't know how to save them (by the way, I can transfer the file without apollo-upload-client).
I really like GraphQL, but uploading files is a big deal. If I don't solve it, I will be forced abandon this technology.
P.S. I didn't find any information on how to upload files via GraphQL at all. Maybe it is necessary to work with files in a different way? I will be grateful for any help
So I want to do pixel manipulation in my Django app, and I want the user to be able to provide links to their own image files. I already saw several solutions, including proxy servers, but I can't seem to get any of them to work, and most of them are specifically for JSON and not images.
The latest one I tried involves using the django corsheaders plugins that adds the cross origin resource sharing headers to responses, but I'm unsure as to what responses exactly are—I'm pretty new to servers.
In any case, this is the error I keep running into:
ImageEditor.js:509 Uncaught SecurityError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
I'm looking for some way to serve images from other domains onto my website and to manipulate their pixels.
Thanks in advance, and please, explain it as though I was someone who doesn't understand anything about servers. :D
I'm really confused with the process of uploading a file (image or pdf in my case) to a Django app programmatically (via HTTP POST or PUT request). I've read the doc but I must admit it hasn't helped me get through. The most confusing part to me is the template (and form) : why do I need to specify a template and form in the view ?
I just want to send a file to a directory, and I'd like to know what exactly is needed in order to do so on the Django part as well as on the request part (content-type... ?)
I'd be really grateful to anyone able to show me some direction here..
You don't say what doc you're reading, so it's hard for us to tell what you mean. But if you're planning on doing a programmatic upload, you don't need a template, of course. You do however need some code that accepts the POST and processes the upload: you can do that with a form, or simply access the data in request.FILES and do what you want with it yourself.
Edit It's true that that page doesn't make any reference to uploading programmatically, because most people's use cases are uploading through the browser, via a form. But the page does explain how to handle uploaded files, which is the only bit that you need.
I am sorry if this question is already posted somewhere.
I am very new to Django. I have been googling around for quite a long time for sample codes to upload large files using Django, but goes in vain.
Can anyone help me with some sample code for uploading large files in Django or provide relavant reliable link(s)?
Thanks in advance.
Django itself handles large files uploads quite well (the whole file is not loaded to memory since 1.0, see http://code.djangoproject.com/ticket/2070).
But django usually sits behind web server and there is often a limit over request body. So Web server config should be probably adjusted (if you are using apache, look at http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestbody ).
There is this called django-video. I haven't tried it though. I have used django-basic-apps
which can handle video, music and image uploads.