Gcode file transfer to Moonraker via HTTP

20 ビュー (過去 30 日間)
will aston
will aston 2023 年 11 月 2 日
回答済み: Deep 2024 年 8 月 23 日
I am connecting to a Moonraker API server via HTTP using the webwrite() function. This has been succesful when sending simple data such as individual Gcode commands.
The problem I am having is sending a complete .gcode file via HTTP. This is possible and is shown in the Moonraker documentation but i have not been successful ata implementing this so far.
From Moonraker API Doc (https://moonraker.readthedocs.io/en/latest/web_api/#file-upload)
POST /server/files/upload`
Content-Type: multipart/form-data
------FormBoundaryemap3PkuvKX0B3HH
Content-Disposition: form-data; name="file"; filename="myfile.gcode"
Content-Type: application/octet-stream
<binary data>
------FormBoundaryemap3PkuvKX0B3HH--
  1 件のコメント
Ganesh
Ganesh 2023 年 12 月 7 日
Hi,
Could you please elaborate on the response you receive and the specific MATLAB Code you are using for this?
Are you recieving an error if you send the contents of the .gcode file, or if you send "myfile.gcode" as a parameter?

サインインしてコメントする。

回答 (1 件)

Deep
Deep 2024 年 8 月 23 日
Hi Will,
I understand that you are trying to send a GCODE file from MATLAB to a Moonraker API server. The Moonraker documentation snippet that you have shown indicates that a “multipart/form-data” HTTP request needs to be initiated.
Unfortunately, MATLAB's webwrite function does not support multipart/form-data requests, which are necessary for uploading files as described in the Moonraker API documentation. However, you can use MATLAB's HTTP interface to accomplish this task. The following resources from MathWorks should provide guidance on sending multipart form messages:
  1. Send Multipart Form Messages - https://www.mathworks.com/help/matlab/matlab_external/send-multipart-form-messages.html
  2. MultipartProvider - https://www.mathworks.com/help/matlab/ref/matlab.net.http.io.multipartprovider-class.html
Hope this helps!

カテゴリ

Help Center および File ExchangeWeb Services についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by