MCPcopy Create free account
hub / github.com/ptmt/react-native-macos / getParts

Method getParts

Libraries/Network/FormData.js:64–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

62 }
63
64 getParts(): Array<FormDataPart> {
65 return this._parts.map(([name, value]) => {
66 var contentDisposition = 'form-data; name="' + name + '"';
67
68 var headers: Headers = {'content-disposition': contentDisposition};
69
70 // The body part is a "blob", which in React Native just means
71 // an object with a `uri` attribute. Optionally, it can also
72 // have a `name` and `type` attribute to specify filename and
73 // content type (cf. web Blob interface.)
74 if (typeof value === 'object' && value) {
75 if (typeof value.name === 'string') {
76 headers['content-disposition'] += '; filename="' + value.name + '"';
77 }
78 if (typeof value.type === 'string') {
79 headers['content-type'] = value.type;
80 }
81 return {...value, headers, fieldName: name};
82 }
83 // Convert non-object values to strings as per FormData.append() spec
84 return {string: String(value), headers, fieldName: name};
85 });
86 }
87}
88
89module.exports = FormData;

Callers 3

convertRequestBodyFunction · 0.80
sendRequestMethod · 0.80
FormData-test.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected