Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #94228
| From | Simmo <steve@bellissimmo.com> |
|---|---|
| Subject | Re: File Upload in Restful Flask |
| Date | 2015-07-20 12:09 +0100 |
| References | <c213a890-0e01-43dd-9cd4-e0dcba3c196f@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.782.1437390589.3674.python-list@python.org> (permalink) |
On 20/07/2015 11:13, subhabrata.banerji@gmail.com wrote:
> Dear Group,
>
> I am trying to learn Rest framework through Restful Flask.
> My initial exercises went fine with https://flask-restful.readthedocs.org/en/0.3.3/quickstart.html
>
> Now I want to upload file through Restful Flask. I tried to check the web for reference.
> I got these urls,
> (i) http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file
> (ii) http://stackoverflow.com/questions/28982974/flask-restful-upload-image
> (iii) http://blog.luisrei.com/articles/flaskrest.html
>
> But the question I am stuck with what are the things I have to change in the example of quickstart tutorial so that I may be able to upload file. Or if any one may kindly suggest with a small example.
>
> If any one of the esteemed members may kindly suggest.
>
> Regards,
> Subhabrata Banerjee.
>
I'm no expert on Python or REST but the example
>>> url = 'http://httpbin.org/post'
>>> files = {'file': open('report.xls', 'rb')}
>>> r = requests.post(url, files=files)
>>> r.text
...
seems quite straightforward so I would suggest substituting your URL for
'http://httpbin.org' and your file name (possibly with full pathname)
for 'report.xls'.
Give it a try and report back...
Steve S
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
File Upload in Restful Flask subhabrata.banerji@gmail.com - 2015-07-20 03:13 -0700
Re: File Upload in Restful Flask Simmo <steve@bellissimmo.com> - 2015-07-20 12:09 +0100
Re: File Upload in Restful Flask subhabrata.banerji@gmail.com - 2015-07-20 04:57 -0700
Re: File Upload in Restful Flask Simmo <steve@bellissimmo.com> - 2015-07-20 14:08 +0100
Re: File Upload in Restful Flask subhabrata.banerji@gmail.com - 2015-07-20 06:47 -0700
csiph-web