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

4 Ansichten (letzte 30 Tage)
Haonan Shen
Haonan Shen am 17 Jan. 2018
Beantwortet: Henrik Pedersen am 2 Jan. 2020
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?

Antworten (1)

Henrik Pedersen
Henrik Pedersen am 2 Jan. 2020
Did you ever solve this issue...?

Kategorien

Mehr zu Earth and Planetary Science finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!