document-picker icon indicating copy to clipboard operation
document-picker copied to clipboard

Audio Not Uploding return error [Error: Network Error]

Open shivani2911 opened this issue 6 years ago • 3 comments

hello gays I'm facing the issue when uploading the audio on the server it returns me network error every I try multiple things to solve this but till not working
here is my code to select the audio file

const results = await DocumentPicker.pick({ type: [DocumentPicker.types.audio] }) console.log('res : ' + JSON.stringify(results)); console.log('URI : ' + results.uri); console.log('Type : ' + results.type); console.log('File Name : ' + results.name); console.log('File Size : ' + results.size);

and here is the code to upload audio fille

  var formdata = new FormData()
  formdata.append(audio_name, audioName)
  formdata.append(company, com_id)
  formdata.append(audio_file, {
    uri: audioPath,
    name: audioFileName,
    type: audioType
  })

return Axios({ url: URL.base_url + url, method: 'POST', data: formdata, headers:{ Accept: 'application/json', 'Content-Type': 'multipart/form-data',} }).then(res => { return res.data }).catch((e) => console.log('POST Method Error => ', e))

till I got this error

'POST Method Error => ', { [Error: Network Error] │ config: │ { url: 'https:///api/Company_Audio_Create/', │ method: 'post', │ data: │ { _parts: │ [ [ 'audio_name', 'Cfvi i' ], │ [ 'company', 12 ], │ [ 'audio_file', │ { uri: 'content://com.android.providers.media.documents/document/audio%3A48', │ name: 'Fiancée', │ type: 'audio/flac' } ] ] }, │ headers: { Accept: 'application/json' }, │ transformRequest: [ [Function: transformRequest] ], │ transformResponse: [ [Function: transformResponse] ], │ timeout: 0, │ adapter: [Function: xhrAdapter], │ xsrfCookieName: 'XSRF-TOKEN', │ xsrfHeaderName: 'X-XSRF-TOKEN', │ maxContentLength: -1, │ maxBodyLength: -1, │ validateStatus: [Function: validateStatus] }, │ request: │ { UNSENT: 0, │ OPENED: 1, │ HEADERS_RECEIVED: 2, │ LOADING: 3, │ DONE: 4, │ readyState: 4, │ status: 0, │ timeout: 0, │ withCredentials: true, │ upload: {}, │ _aborted: false, │ _hasError: true, │ _method: 'POST', │ _perfKey: 'network_XMLHttpRequest_https:///api/Company_Audio_Create/', │ _response: 'Stream Closed', │ _url: 'https:///api/Company_Audio_Create/', │ _timedOut: false, │ _trackingName: 'unknown', │ _incrementalEvents: false, │ responseHeaders: undefined, │ _requestId: null, │ _cachedResponse: undefined, │ _headers: { accept: 'application/json' }, │ _responseType: '', │ _sent: true, │ _lowerCaseResponseHeaders: {}, │ _subscriptions: [] }, │ response: undefined, │ isAxiosError: true, │ toJSON: [Function: toJSON], │ line: 173636, │ column: 26, │ sourceURL: 'http://localhost:8081/index.bundle?platform=android&dev=true&minify=false' } └ 'response audio', undefined

I tried commenting on Flipper or update the flipper version

help me

shivani2911 avatar Nov 04 '20 07:11 shivani2911

i also get this error, than i update the flipper version and it's solved or you can remove the flipper https://github.com/facebook/flipper/issues/1326#issuecomment-653470251

irsyaadbp avatar Nov 17 '20 14:11 irsyaadbp

thanks i already remove that and now it's working fine

On Tue, Nov 17, 2020 at 8:28 PM Irsyaad Budi [email protected] wrote:

i also get this error, than i update the flipper version and it's solved or you can remove the flipper facebook/flipper#1326 (comment) https://github.com/facebook/flipper/issues/1326#issuecomment-653470251

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rnmods/react-native-document-picker/issues/357#issuecomment-728983990, or unsubscribe https://github.com/notifications/unsubscribe-auth/AREKPEOVZTBNJLQZUYNTYALSQKFSRANCNFSM4TJV72WA .

-- Shivani Topiwala Mobile App Developer

shivani2911 avatar Nov 19 '20 04:11 shivani2911

In my case it was an issue of mimeType

shkhaider2015 avatar Jul 27 '22 07:07 shkhaider2015