tencent cloud

Performance Testing Service

Related Agreements
Service Level Agreement
Use Limits
Privacy Policy
Data Processing And Security Agreement
문서Performance Testing Service

FormData.contentType

포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-03-10 17:04:49
FormData.contentType is used to obtain the ContentType field of form-data.
contentType(): string

Return

Type
Description
string
The value of the ContentType field.

Samples

import http from 'pts/http';

const data = open('./sample/tmp.js');

export default function () {
const formData = new http.FormData();
formData.append('text', 'text');
formData.append('file', http.file(data, 'tmp.js'));
// Return "multipart/form-data; boundary=xxxxxx".
console.log(formData.contentType());
const resp = http.post('http://httpbin.org/post', formData.body(), {
headers: {'Content-Type': formData.contentType()}
});
console.log('formData: ', resp.body);
};


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백