Having issues with uploading a file to octoprint print server. The following curl script works fine.
curl -k -H "X-Api-Key: 1234567890" -F "select=true" -F "print=false" -F "file=@Bench.gcode" "http://octopi/api/files/local"
The following code is what I have configured in a button. When I run this code it times out and I have to restart the
server because it becomes non responsive and the application looses the ability to poll the server. This should not timeout
the curl script runs in less than 2 seconds.
[code]Using Xojo.Core
Using Xojo.Data
Dim Octo As New OctoSocket
Dim data As MemoryBlock
data = TextEncoding.UTF8.ConvertTextToData(dataF)
Octo.SetRequestContent(data, “multipart/form-data; boundary=----WebKitFormBoundaryDeC2E3iWbTv1PwMC”)
Octo.RequestHeader(“X-Api-Key”) = apikey
Octo.Send(“POST”, “http://octopi/api/files/local”)[/code]
OctoSocket is the Class where I have defined: Xojo.Net.HTTPSocket
dataF is a constant that contains the following data
------WebKitFormBoundaryDeC2E3iWbTv1PwMC
Content-Disposition: form-data; name="file"; filename="@Bench.gcode"
Content-Type: application/octet-stream
M109 T0 S220.000000
T0
G21
G90
...
------WebKitFormBoundaryDeC2E3iWbTv1PwMC
Content-Disposition: form-data; name="select"
true
------WebKitFormBoundaryDeC2E3iWbTv1PwMC
Content-Disposition: form-data; name="print"
false
------WebKitFormBoundaryDeC2E3iWbTv1PwMC--
The file content is embedded for simplicity and is the same content the curl script uploads. Once I have it working
I can then read the complete file in. I can successfully post to the server with json data without any issues. So I must be doing
something wrong in how I am sending the upload post. Can anybody determine what I am doing wrong?
Thanks