3

I use react-native-camera for capturing images and saving them in cameraRoll (CaptureTarget) for iOS devices, on capture I get image path in the following form

"assets-library://asset/asset.JPG?id=8B55D3E5-11CE-439A-8FC6-D55EB1A88D7E&ext=JPG"

How to use this path to display the image in Image component (from react-native)?

Previously I was using disk as CaptureTarget option, and I was able to show that image url Image component but now the requirements are to save image in camera roll?

2
  • did you work this out at all ? Commented Apr 8, 2017 at 9:33
  • @ajonno please see my answer Commented Apr 10, 2017 at 12:55

1 Answer 1

2

I have used RNFetchBlob to get base64 from "assets-library://.." url, my capture function is

this.camera.capture()
      .then((data) => {
        // console.log(data);
        RNFetchBlob.fs.readFile(data.path, 'base64')
          .then((base64data) => {
            let base64Image = `data:image/jpeg;base64,${base64data}`;
            this.props.addImagesToUntagged(data.path);
          })

      })

after that i give user some in-app functionality on this base64 data and finally when I need to send this to s3 server, I use axios & RNFetchBlob to send this data.following code gives me signed url for s3

axios.get(ENDPOINT_TO_GET_SIGNED_URL, {params:{'file-name': file.name,'file-type': file.type,"content-type": 'evidence'}})
  .then(function (result) {
    //  console.log(result);
    returnUrl = result.data.url;
    var signedUrl = result.data.signedRequest;
    return uploadFile(file,signedUrl)
  })

and in my uploadFile function i upload images through following code

RNFetchBlob.fetch('PUT', signedUrl,
    {'Content-Type' : file.type},
    RNFetchBlob.wrap(file.uri)
  )
  .then(resolve)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.