本机反应-相机胶卷返回的uri没有文件的扩展名

时间:2019-04-19 04:10:53

标签: ios react-native react-native-ios camera-roll

React native具有很好的库,例如CameraRoll,它使我们能够访问手机的媒体文件。但是,返回的uri缺少扩展名:

{ node: 
  { timestamp: 1344461389.8,
   type: 'image', <= it is used to be 'image/png' instead of 'image'
   group_name: 'Camera Roll',
   location: 
    { altitude: 0,
      longitude: -14.538611666666666,
      latitude: 64.752895,
      heading: 0,
      speed: 0.8999988197665498 },
   image: 
    { width: 1668,
      uri: 'ph://99D53A1F-FEEF-40E1-8BB3-7DD55A43C8B7/L0/001', <= there is no file's extension
      height: 2500,
      isStored: true,
      playableDuration: 0 } } },

在这种情况下,如果您知道获取扩展程序或其他解决方法,请告诉我。

提前谢谢!

2 个答案:

答案 0 :(得分:1)

我已经使用expo-media-library解决了这个问题 https://docs.expo.io/versions/latest/sdk/media-library

     async myFunc() {
     let uri = "ph://ED7AC36B-A150-4C38-BB8C-B6D696F4F2ED/L0/001"
     let myAssetId = uri.slice(5);
     let returnedAssetInfo = await MediaLibrary.getAssetInfoAsync(myAssetId);
     returnedAssetInfo // you will have all the information in here

}}`

答案 1 :(得分:0)

我有一个解决方法,返回的扩展名不是很漂亮,但是可以使用:

从文件RNCCameraRollManager.m:

请添加这两行

enter image description here

enter image description here

现在您有了扩展名。

这里是环境:

“ @ react-native-community / cameraroll”:“ 1.0.3”,
“反应”:“ 16.8.3”,
“ react-native”:“ 0.59.5”

相关问题