curl / Mailing Lists / curl-users / Single Mail

curl-users

I cannot upload my file through an API via cURL?

From: Afu Ra via curl-users <curl-users_at_cool.haxx.se>
Date: Wed, 12 Apr 2017 10:27:33 +1000

Hello,

I'm trying to upload firmware to a computer via API, which normally I do
through the click of a button on our web server. This is the 'General'
header:

   1. Request URL:
   http://192.168.243.179:8080/firmware/linux/
   2. Request Method:
   POST
   3. Status Code:
   200 OK
   4. Remote Address:
   192.168.243.179:8080
   5. Referrer Policy:
   no-referrer-when-downgrade

On the firmware page, I would click a button and it uploads my firmware
file to /firmware/linux/.

This is my response header when I submit the firmware file:

HTTP/1.1 200 OK
Date: Tue, 11 Apr 2017 23:22:43 GMT
Content-Length: 134
Content-Type: text/html;charset=utf-8
Server: CherryPy/3.2.2

Here is my request header:

POST /firmware/atlas_linux HTTP/1.1
Host: 192.168.243.179:8080
Connection: keep-alive
Content-Length: 63067756
Cache-Control: max-age=0
Origin: http://192.168.243.179:8080
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
Content-Type: multipart/form-data;
boundary=----WebKitFormBoundarynaUDhUWIArqOTvuC
Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Referer: http://192.168.243.179:8080/firmware/
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6

and my request payload:

------WebKitFormBoundarynaUDhUWIArqOTvuC
Content-Disposition: form-data; name="image";
filename="uImage-jjr-dvr-atlas_v1.0.1-16-g5e31aec"
Content-Type: application/octet-stream
------WebKitFormBoundarynaUDhUWIArqOTvuC--

I am using the following cURL command to imitate these requests to POST my
firmware file over to the computer:

*curl -i -X POST -d @"C:\Users\name\Documents\firmware/firmwarefile"
http://192.168.243.179:8080/firmware/linux/
<http://192.168.243.179:8080/firmware/linux/> -H "Content-Type:
multipart/form-data"*

The above yields the error 'ValueError: Invalid boundary in multipart form:
'''

I then try it with a boundary as supplied in my request header:

*curl -i -X POST -d @"C:\Users\name\Documents\firmware/firmwarefile"
http://192.168.243.179:8080/firmware/linux/
<http://192.168.243.179:8080/firmware/linux/> -H *
*"Content-Type: multipart/form-data;
boundary=----WebKitFormBoundarynaUDhUWIArqOTvuC"*

The above command yields no errors, but I then check if the firmware has
been updated, and it hasn't.

Am I posting my file correctly? I don't understand why the firmware file is
not being pushed through.

Thanks for the help in advance.

-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-04-12