2017-12-24 14 views
0

카메라를 사용하여 사진을 찍고 AWS S3에 업로드 할 수있는 반응 기본 응용 프로그램을 만듭니다.React-Native Camera 오류 - 에셋 라이브러리에 적합한 URL 요청 처리기가 없습니다.

사진을 클릭하여 내 iPhone 카메라 롤에 이미지를 저장할 수 있습니다. 나는 이미지를 업로드하려고 할 때 다음과 같이하지만, 나는 오류 No suitable URL request handler found for assets-library://asset를 얻을 : 여기 iOS image upload error 은 코드입니다 : 나는이 문제를 해결 libRCTCameraRoll.a을 추가

import Camera from 'react-native-camera';  
import {RNS3} from "react-native-aws3"; 

    class NCamera extends React.Component { 
     takePicture() { 
      this.camera.capture() 
       .then((data) => { 
        const file = { uri: data.path, name: 'image.png', type: 'image/png',} 
        const options = { 
         keyPrefix: "images/", 
         bucket: "my-bucket-name", 
         region: "us-east-1", 
         accessKey: "key", 
         secretKey: "secret-key", 
         successActionStatus: 201 
        } 
        RNS3.put(file, options) 
         .then(response => { 
          if (response.status != 201) 
           console.log('Error uploading file to S3'); 
          else 
           console.log(response.body); 
        }) 
         .catch (error => console.log(`Error uploading: ${error}`)); 
       }) 
       .catch(err => console.log(err)); 
     } 
     render() { 
      return (
       <Camera 
        ref={(cam) => { 
         this.camera = cam; 
        }} 
        style={styles.preview} 
        aspect={Camera.constants.Aspect.fill}> 
        <Text style={styles.capture} onPress={this.takePicture.bind(this)}>[CAPTURE]</Text> 
       </Camera> 
      ); 
     } 
    } 

솔루션.

다음은 단계입니다.
1. xcode에서 RCTCameraRoll.xcodeproj을 엽니 다. 파일은 node_modules/react-native/Libraries/CameraRoll
에서 찾을 수 있습니다. 2. 빌드 단계에서 libRCTCameraRoll.a (아래 스크린 샷)을 추가하십시오. 이 IOS에있는 경우

enter image description here

답변

1

, 난 당신이 파일의 URL이 제대로 해결 될 수 있도록 엑스 코드에 libRCTCamera.a을 연결할 필요가 있다고 생각. 자세한 내용은 this medium article을 참조하십시오.

+0

'libRCTCameraRoll.a'를 추가하면 문제가 해결되었습니다. 솔루션으로 내 게시물을 업데이트했습니다. 링크를 가져 주셔서 감사합니다. 문제 해결에 도움이되었습니다. –