Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

Use formData to upload two filetypes in an iOS app?

$
0
0

I would like my uploadFormPage() function to be able to take jpegs and pdf's. Is it possible for me to have 2 file types for the same FormData() const?`

export function uploadFormPage(documentId, formId, file, callback) {  return async dispatch => {try {  const formData = new FormData();  formData.append('page', {    name: `document-${documentId}-${formId}-${Date.now()}.jpg`,    type: 'image/jpeg',    uri: file,  });  const result = await Api.uploadFiles(formData);  const entity = {    id: formId,    resourceKey: result.page,  };  const rsp = await Api.uploadFormPage(documentId, entity);  dispatch({type: LOAD_DOCUMENTS, data: rsp});  callback(null, rsp);} catch (e) {  callback(e, null);}};}

Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>