[python-uk] File upload with 'requests' package

Alistair Broomhead alistair.broomhead at gmail.com
Fri Dec 2 12:21:33 EST 2016


Not sure that really explain why curl could do it

On Fri, 2 Dec 2016 at 17:19 Edward Hartley <ed.hartley at gmail.com> wrote:

> Prolly a server side limit.
>
> On 2 Dec 2016, at 16:15, Alistair Broomhead <alistair.broomhead at gmail.com>
> wrote:
>
> Hi Florian,
>
> This is probably not the best forum for Q&A, but I think you might need to
> look at
> http://docs.python-requests.org/en/master/user/advanced/#chunk-encoded-requests
>
> Al
>
> On Fri, 2 Dec 2016 at 16:11 Florian BERBAR <florian.berbar at urssaf.fr>
> wrote:
>
> Good evening everyone,
>
> I try to post a file (100MB) on a Web form with python3 and the 'requests'
> package.
>
> This is my implementation :
>
>
> --------------------------------------BOF-------------------------------------------------
>
> #!/usr/local/bin/python3 -u
>
> import requests
>
> email="user at srv.fr"
>
> try:
>    res = requests.post('http://server/Upload/upload.php',
>                        files={'aFile': open('/tmp/test.zip','rb')},
>                        data={'email': email, 'submitFile': 'Envoyer le
> fichier'})
>
> except requests.exceptions.Timeout:
>    print('timeout')
>
> print(res.content)
>
>
> --------------------------------------EOF-------------------------------------------------
>
> This code semas to be correct, but it return a *ConnectionResetError:
> [Errno 104] Connection reset by peer*
>
> The same upload with curl work perfectly with this command :
>
> curl --form aFile=@"/tmp/test.zip" --form email="user at srv.fr" --form
> submitFile="Envoyer le fichier" http://server/Upload/upload.php
>
> Thanks to the advance
>
> Florian_______________________________________________
> python-uk mailing list
> python-uk at python.org
> https://mail.python.org/mailman/listinfo/python-uk
>
> _______________________________________________
> python-uk mailing list
> python-uk at python.org
> https://mail.python.org/mailman/listinfo/python-uk
>
> _______________________________________________
> python-uk mailing list
> python-uk at python.org
> https://mail.python.org/mailman/listinfo/python-uk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-uk/attachments/20161202/933bab2d/attachment-0001.html>


More information about the python-uk mailing list