Help Center/
Huawei Cloud Astro Zero/
FAQs/
Application Backend Development/
Do Huawei Cloud Astro Zero Scripts Support multipart/form-data Requests?
Updated on 2025-03-20 GMT+08:00
Do Huawei Cloud Astro Zero Scripts Support multipart/form-data Requests?
The standard script library provides multipart to support multipart/form-data requests. The sample code is as follows:
import * as http from 'http'; import * as mp from 'multipart'; import * as buffer from 'buffer'; let w = mp.newWriter(); let bytes = buffer.from("hello, Astro Zero"); w.setBoundary("--ABC"); let mimeHeader = { "Content-Disposition": ['form-data; name="upload_file"; filename="a.txt"'], "Content-Type": ['application/octet-stream'] } w.writeBuffer(mimeHeader, bytes); w.writeField("name", "Trump"); w.close(); let client = http.newClient(); let req : http.Request = { data: w.buffer().bytes(), headers: { "Content-Type": w.formDataContentType(), } } let resp = client.post('ip', req); console.log("response = ", resp);
Parent topic: Application Backend Development
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot