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?
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Earth and Planetary Science 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!