-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upload files throught POST. #31
Comments
Short answer, dRest doesn't support file uploads out of the box. I've not interfaced with an API that accepts file uploads, however it is entirely possible. You simply need to sub-class RESTResourceHandler and override the http://drest.readthedocs.org/en/latest/customization.html I could potentially help with this, however I would need an API example to work with to really know what the API is expecting. |
I'll give it a try. Thank you! If you need an API example you can use the excellent httpbin.org. curl -i -F name=test -F [email protected] http://httpbin.org/post
httpbin.org will return a JSON with all the uploaded contents. After playing with this I think that a more correct interface could be: myapi.myresource.post(params={'foo': 1},
files={'bar.raw': open('bar.raw', 'r').read()}) Because the name of the file is mandatory and HTTP allows you to send multiple files at once. |
@nilp0inter thanks for the followup, and sorry for the delay in my response. As mentioned, I think the best approach here is to customize dRest to work how you need it to for this specific purpose. Have you had any luck with that, or do you still need some help with it? |
Hi @derks , unfortunately I couldn't work on it because I've been very busy. Nevertheless I'm still interested in making the patch. I seen the mentioned code and it doesn't look so difficult how I thought in the beginning. I'll be back with a patch soon. Thank you! |
Any luck on this issue? |
@keithjjones , sorry I never make any progress in the issue and I never will, because we stopped using the library as a dependency in our project (nothing wrong with the library, but our requirements changed) |
Hi,
Is it possible to upload a file using the POST method of the resources?
Something like:
Thank you.
The text was updated successfully, but these errors were encountered: