()
| 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 | |
| 89 | module.exports = FormData; |
no outgoing calls
no test coverage detected