React-native-document-picker: iOS files missing or deleted after several minutes

Created on 30 Aug 2019  路  6Comments  路  Source: rnmods/react-native-document-picker

Acessing the file and filepath are working as intended initially but after a period of several minutes accessing the file again will result in the file not being found or missing.

This is on iOS. Could it be that because the files are in a temporary path /tmp/ they're being cleaned?

What would be the recommended solution here? Copying or moving the file to another directory?

FAQ files_deleted tmp

Most helpful comment

@pt9dat i solved this by moving the video file using react-native-filesystem,

i suspect it's a temporary file so i moved it to the cache directory

hope this helps

All 6 comments

same here, both on Android and iOS

@pt9dat i solved this by moving the video file using react-native-filesystem,

i suspect it's a temporary file so i moved it to the cache directory

hope this helps

@IvanCaceres thanks so much

@IvanCaceres do you have some code to show. I would think that it is rather trivial, but the copyFile callback never triggers on Android.

          const folder = `${TemporaryDirectoryPath}/fileUpload/${Date.now()}`
          const newPath = `${folder}/${file.name}`
          console.warn('copying file from %s to', file.uri, newPath)

          try {
            await mkdir(folder, {
              NSURLIsExcludedFromBackupKey: true,
            })
            console.warn('MKDIR DONE') // called
            await copyFile(file.uri, newPath)
            console.warn('COPY DONE') // never called
          } catch (e) {
            // never called
         }

Can we get a solution ??

On iOS, the solution is to use the copyTo option.

Closing because the original issue is resolved.

Was this page helpful?
0 / 5 - 0 ratings