Issue regarding file System upload

Please provide the following:

  1. SDK Version: 38
  2. Platforms(Android/iOS/web/all):Android

Hi @notbrent @bacon i think their is a minor typo in expo file system docs for FileSystem.uploadAsync(url, fileUri, options) this is the order of parameters to be sent as per the documentation but it does not work, i tried this FileSystem.uploadAsync( fileUri, url, options) with this it did search for the file uri and not the upload url, but the issue still is that, it says, Directory for /document/primary:Download/random100-livai.zip doesn’t exist. When i tried to check using FileSystem.getInfoAsync(fileUri, options), i got ,

Object {
  "exists": true,
  "isDirectory": false,
  "size": 1999675,
  "uri": "content://com.android.externalstorage.documents/document/primary%3ADownload%2Frandom100-livai.zip",
}

But while uploading the file it says (Directory for /document/primary:Download/random100-livai.zip doesn’t exist.)

Can you please help me out with this, Thank You.

Ive also tried to use readFileAsStringAsync, but somehow that too it not working for me,

        let op = {
            encoding: FileSystem.EncodingType.Base64
        }

        try {
            let res = await FileSystem.readAsStringAsync(file.uri, op)
            console.log(res)
        } catch (err) {
            console.log(err)
        }
Unsupported scheme for location 'content://com.android.externalstorage.documents/document/primary%3ADCIM%2FGame%20media%2FExpo%2FExpo_2019-07-06-17-50-12.jpg'
 let options = {
            type: "application/zip",
            // copyToCacheDirectory: false
        }
        try {            
            let file = await DocumentPicker.getDocumentAsync(options)
            console.log(file)
            this.setState({ file })
            
        } catch (err) {
            console.log(err)
        }

I just commented out the copyToCacheDirectory from picker options, and i started to get uri as file://, so the below error is gone

(Directory for /document/primary:Download/random100-livai.zip doesn't exist.)

But now im getting,

java.lang.Double cannot be cast to java.lang.Integer
- node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:103:50 in promiseMethodWrapper
- node_modules/@unimodules/react-native-adapter/build/NativeModulesProxy.native.js:15:23 in moduleName.methodInfo.name
- node_modules/expo-file-system/build/FileSystem.js:115:17 in uploadAsync
- node_modules/regenerator-runtime/runtime.js:45:36 in tryCatch
- node_modules/regenerator-runtime/runtime.js:271:29 in invoke
- node_modules/regenerator-runtime/runtime.js:45:36 in tryCatch
- node_modules/regenerator-runtime/runtime.js:135:27 in invoke
- node_modules/regenerator-runtime/runtime.js:170:16 in Promise$argument_0
- node_modules/promise/setimmediate/core.js:45:6 in tryCallTwo
- node_modules/promise/setimmediate/core.js:200:22 in doResolve
- node_modules/promise/setimmediate/core.js:66:11 in Promise
- node_modules/regenerator-runtime/runtime.js:169:15 in callInvokeWithMethodAndArg
- node_modules/regenerator-runtime/runtime.js:192:38 in enqueue
- node_modules/regenerator-runtime/runtime.js:216:8 in exports.async
- node_modules/expo-file-system/build/FileSystem.js:110:7 in uploadAsync
* src/screens/ProjectManagementScreen.js:114:18 in _uploadFile
- node_modules/regenerator-runtime/runtime.js:45:36 in tryCatch
- node_modules/regenerator-runtime/runtime.js:271:29 in invoke
- node_modules/regenerator-runtime/runtime.js:45:36 in tryCatch
- node_modules/regenerator-runtime/runtime.js:135:27 in invoke
- node_modules/regenerator-runtime/runtime.js:145:18 in Promise.resolve.then$argument_0
- node_modules/promise/setimmediate/core.js:37:13 in tryCallOne
- node_modules/promise/setimmediate/core.js:123:24 in setImmediate$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:135:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:183:16 in _callImmediatesPass
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:446:30 in callImmediates
* [native code]:null in callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:396:6 in __callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:144:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:373:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:143:4 in flushedQueue
* [native code]:null in flushedQueue
* [native code]:null in invokeCallbackAndReturnFlushedQueue

Attaching my code below

 let headers = {
            'content-type': 'multipart/form-data',
            Authorization: token
        }

        let options = {
            headers: headers,
            httpMethod: "POST",
            uploadType: FileSystem.FileSystemUploadType.MULTIPART,
            fieldName: "file"
        }
 try {
            let upload = await FileSystem.uploadAsync(file.uri, endpoint, options)
            console.log(upload)
        } catch (err) {
            console.log(err)
        }

Sorry for editing this constantly, but ive been trying it for hours, thought would be better to update will the latest problem. Thanks

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.