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

4 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Earth and Planetary Science 的更多信息

Community Treasure Hunt

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

Start Hunting!