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

问题描述 投票:2回答:1

React native有一个很好的lib,比如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 } } },

如果您知道如何获得扩展或在这种情况下的任何解决方案,请告诉我。

先感谢您!

ios react-native react-native-ios camera-roll
1个回答
1
投票

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

从文件RNCCameraRollManager.m:

Please add these 2 lines

NSString *const extension = [asset valueForKey: @"uniformTypeIdentifier"];

enter image description here

and

@"extension": extension,

enter image description here

现在你有了扩展名。

这是环境:

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

© www.soinside.com 2019 - 2024. All rights reserved.