How to construct the body and upload the files of multipart/form-data

4 ビュー (過去 30 日間)
Haonan Shen
Haonan Shen 2018 年 1 月 17 日
回答済み: Henrik Pedersen 2020 年 1 月 2 日
I am trying to pass the files to the API interface with multipart/form-data. But I am not sure how to construct the body as below:
------WebKitFormBoundaryoeTA5ctzJ87vDL0x Content-Disposition: form-data; name="file"; filename="DefaultCsv.csv" Content-Type: application/vnd.ms-excel
------WebKitFormBoundaryoeTA5ctzJ87vDL0x--
I have written the codes like:
boundary='----WebKitFormBoundary52x5ruT8nrmA8Ek2'; body=sprintf('%s\n%s\n%s\n%s',boundary,'Content-Disposition:form-data;name="file";filename="DefaultCsv.csv"','Content-Type:application/vnd.ms-excel',boundary); body_ = matlab.net.http.MessageBody(body); body_.Payload=body;
But it does not work.
In addition how could I upload the files by this form?

回答 (1 件)

Henrik Pedersen
Henrik Pedersen 2020 年 1 月 2 日
Did you ever solve this issue...?

カテゴリ

Help Center および File ExchangeEarth and Planetary Science についてさらに検索

Community Treasure Hunt

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

Start Hunting!