Cached document from DocumentPicker doesn't exist

Please provide the following:

  1. SDK Version: 4.10.1
  2. Platforms(Android/iOS/web/all): Android
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

Hello, I’m having some troubles with uploading documents.
It seems like the documents doesn’t exist in cache.

const handleUploadDocument = async () => {
    const doc = await DocumentPicker.getDocumentAsync()
    if (doc.type !== 'cancel') {
        console.log(doc)
        FileSystem.getInfoAsync(doc.uri).then((t) => console.log('Does it exist?', t.exists))
        }
    }
}

This prints out:

Object {
  "name": "20210823_220428.jpg",
  "size": 3228884,
  "type": "success",
  "uri": "/data/user/0/host.exp.exponent/cache/ExperienceData/%40stephanbv%2F24mobiApp/DocumentPicker/e859f01b-082f-4927-87e5-16674d2bf29e.jpg",
}
Does it exist? false

I also have a ImagePicker with almost identical code:

const handleTakePhoto = async () => {
    const result = await ImagePicker.launchCameraAsync({
        mediaTypes: MediaTypeOptions.Images,
        allowsEditing: true,
        quality: 0.4,
    })
    if (!result.cancelled) {
        console.log(result)
        FileSystem.getInfoAsync(result.uri).then((t) => console.log('Does it exist?', t.exists))
    }
}

This prints out:

Object {
  "cancelled": false,
  "height": 3226,
  "type": "image",
  "uri": "file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540stephanbv%252F24mobiApp/ImagePicker/6a2d9b48-dc68-4c87-9c2b-8fa5e0c184a5.jpg",
  "width": 2420,
}
Does it exist? true

So the document from ImagePicker exist in cache, but not the DocumentPicker.
Anyone got any tips to how I can move forward on this issue?

ImagePicker v 10.2.2
DocumentPicker v 9.2.4

After more testing, I can assure there is something wrong with how the DocumentPicker stores documents to cache. Just bumping the version down doesnt fix the problem.

It all works on Expo SDK 40.0.0 and DocumentPicker v 8.

I managed to get the document by passing copyToCacheDirectory: false to the DocumentPicker, Hopefully this will work until DocumentPicker gets fixed.

Thanks for following up with your findings @stephanbv! Would you mind creating a github issue detailing all your insights and a public repro case we can use to test locally?

Cheers,
Adam

Thanks. I’ve created a new issue at Cached document from DocumentPicker doesn’t exist · Issue #14335 · expo/expo · GitHub

I’m having troubles converting the file to a base64 when using copyToCacheDirectory: false
This gives me a uri starting with content://. I am able to display an image inside <Image /> with that uri, however I’m not able to create a base64 out of it. The url looks like this: content://com.android.providers.media.documents/document/image%3A1

I tried converting it to a file:///path using FileSystem.downloadAsync()however this function seems to only take in a http://or https://

Any temporary suggestions?

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