Uploading a file per the REST API


I'm trying to upload a file using the REST API. It indicates that I need to include a location. In the example, I don't see where the location would be specified as either a form field or otherwise in the header. Here is the example I'm referring to:

POST /api/files/sdcard HTTP/1.1
Host: example.com
X-Api-Key: abcdef...
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryDeC2E3iWbTv1PwMC

Content-Disposition: form-data; name="file"; filename="whistle_v2.gcode"
Content-Type: application/octet-stream

M109 T0 S220.000000
Content-Disposition: form-data; name="select"

Content-Disposition: form-data; name="print"


I was trying to post locally, so the first line would be the following if I am understanding correctly (by the way, the docs indicate that uploading to SD cards is not yet implemented, yet it appears that the example is for SD cards):

POST /api/files/local HTTP/1.1

If the location is appended to that, then it might be something like:

POST /api/files/local/funProject HTTP/1.1

If it is a form variable, then it would be the following:

Content-Disposition: form-data; name="location"


Any assistance is appreciated!

Cant upload embedded gcode

Small correction - it does look like you can upload to SD Cards, but not create folders there. I misread it the first time.

Still not absolutely sure how to provide the location.


Never mind, found it. The title of the subsection is the following:

POST /api/files/(string: location)

Location is appended to the end of the post location.


Can you share the complete solution? Thanks.