Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #94228

Re: File Upload in Restful Flask

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.031
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'restful': 0.09; 'url:blog': 0.10; 'python': 0.10; 'suggest': 0.15; 'from:addr:steve': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:File': 0.16; 'substituting': 0.16; 'wrote:': 0.16; 'example.': 0.18; 'steve': 0.18; '>>>': 0.20; 'file.': 0.22; 'trying': 0.22; 'seems': 0.23; 'tried': 0.24; 'header:In-Reply- To:1': 0.24; 'header:User-Agent:1': 0.26; 'example': 0.26; 'header:X-Complaints-To:1': 0.26; 'rest': 0.26; 'question': 0.27; "skip:' 10": 0.28; 'went': 0.28; 'fine': 0.28; 'initial': 0.28; 'tutorial': 0.29; "i'm": 0.30; 'file': 0.34; 'quite': 0.35; 'but': 0.36; 'url:org': 0.36; 'framework': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'things': 0.38; 'files': 0.38; 'url:en': 0.39; 'to:addr:python.org': 0.40; 'group,': 0.60; 'url:3': 0.60; 'your': 0.60; 'email addr:gmail.com': 0.62; 'charset:windows-1252': 0.62; 'url:user': 0.63; 'url:0': 0.63; 'kindly': 0.64; 'dear': 0.67; 'expert': 0.70; 'url:readthedocs': 0.84; '(ii)': 0.91; 'esteemed': 0.91; 'url:latest': 0.91; 'urls,': 0.91; 'received:2': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Simmo <steve@bellissimmo.com>
Subject Re: File Upload in Restful Flask
Date Mon, 20 Jul 2015 12:09:28 +0100
References <c213a890-0e01-43dd-9cd4-e0dcba3c196f@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 2.221.110.132
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
In-Reply-To <c213a890-0e01-43dd-9cd4-e0dcba3c196f@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.782.1437390589.3674.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1437390589 news.xs4all.nl 2865 [2001:888:2000:d::a6]:42227
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:94228

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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