拍照并将其保存到相机胶卷

时间:2019-10-02 20:52:14

标签: javascript reactjs react-native react-native-camera

我想在我的Android应用中拍照,然后将其保存到相机胶卷中。我正在使用CameraRollRNCamera,但是在相机胶卷中看不到图像。

函数是:

...
import { RNCamera } from "react-native-camera";
import { CameraRoll } from "react-native";
...

async _takePicture() {
    const data = await this.camera.takePictureAsync({
      quality: 1.0,
      base64: true,
      orientation: "portrait",
      fixOrientation: true
    });
    CameraRoll.saveToCameraRoll(data.uri, "photo");
  }
...

编辑: 我通过添加

解决了
const granted = await PermissionsAndroid.request(
              PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
              {
                title: 'My App Storage Permission',
                message: 'My App needs access to your storage ' +
                  'so you can save your photos',
              },
            );

CameraRoll.saveToCameraRoll(data.uri, "photo"); 之后的

0 个答案:

没有答案