Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android, tries to download local files #10

Open
YousefED opened this issue Oct 16, 2018 · 4 comments
Open

Android, tries to download local files #10

YousefED opened this issue Oct 16, 2018 · 4 comments
Assignees

Comments

@YousefED
Copy link

On android, when I pass a file:// to AssetUtils.resolveAsync(), it will try to download the file, even though it's already on the file system. This results in an error as local files can't be downloaded (unexpected url).

My current workaround:

const fromUri = await AssetUtils.fromUriAsync(localUri);
        fromUri.localUri = fromUri.uri;
        // console.warn(fromUri);

        const uriResolved = await AssetUtils.resolveAsync(fromUri);
        // console.warn(uriResolved);

@sjchmiela sjchmiela self-assigned this Nov 3, 2018
@EvanBacon
Copy link
Contributor

expo/expo#2167

@DEllement
Copy link

DEllement commented Feb 14, 2019

Could be related
expo-pixi - Draw on picture #59

@KnpA
Copy link

KnpA commented Apr 17, 2019

Related, also can't load file from distant URL:

// Test 1
let texture = await ExpoTHREE.loadTextureAsync({ asset: 'URL_OF_DISTANT_FILE'});
texture.localUri = texture.uri;
texture.downloaded = true;
  
// Test 2
let texture = await AssetUtils.fromUriAsync('URL_OF_DISTANT_FILE');
texture.localUri = texture.uri;
texture.downloaded = true;
console.log(texture);

// Test 3
let texture = await AssetUtils.resolveAsync('URL_OF_DISTANT_FILE');
texture.downloaded = true;
texture.localUri = texture.uri;
console.log(texture);

I always got the following error:

[Unhandled promise rejection: Error: unexpected url: file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540knpa%252Fappname/95b6ffc1181ac3fb943311280f776e7e.jpg]
- node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:146:41 in createErrorFromErrorData
- node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:95:55 in <unknown>
- ... 5 more stack frames from framework internals

Related lines of my package.json:

"dependencies": {
    "expo": "^32.0.0",
    "expo-asset-utils": "^1.0.0",
    "expo-cli": "^2.6.14",
    "expo-three": "^3.0.0-alpha.8",
    "react": "16.5.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
  },

Related lines of my app.json:

  "expo": {
    "sdkVersion": "32.0.0",
    "packagerOpts": {
      "assetExts": [
        "obj",
        "mtl",
        "gltf",
        "glb",
        "jpeg",
        "jpg",
        "png"
      ]
    }
  }

@flyskywhy
Copy link

console.warn(await Asset.loadAsync(require('some.png')))

With [email protected] comes from [email protected]
I get the wrong [undefined]

With [email protected] comes from [email protected]
I get the right [{localUri, ...}]

So maybe you should upgrade react-native-unimodules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants