1
votes

I am using image picker for picking image from my phone .image picker provide the response

{height: 33, origURL: "assets-library://asset/asset.JPG?id=9F983DBA-EC35-42B8-8773‌​-B597CF782EDD&ext=JP‌​G", longitude: -17.54892833333333, fileName: "IMG_0003.JPG", uri: "file:///Users/mac/Library/Developer/CoreSimulator/…temfiles‌​/ADC7B1EA-93A0-4A25-‌​B7CA-342BE3EF58BE.jp‌​g", …}

I am using RNFetchBlob for uploading image to firebase. actually i want to upload image using either data or uri not using origURL because i need to reduce the image size before uploading.Currently uploading is not possible using uri

 let rnfbURI = RNFetchBlob.wrap(image.uri)
Blob
    .build(rnfbURI, { type : 'image/png;'})
    .then((blob) => {
      // upload image using Firebase SDK
      firebase.storage()
        .ref()
        .child('images/')
        .put(blob, { contentType : 'image/jpg' })
        .then((snapshot) => {

      }).catch((error) => {
          console.log(error);
              Alert.alert(error);

        })
    });
2

2 Answers

0
votes

are you using https://github.com/react-community/react-native-image-picker in your project? you can try with maxWidth, maxHeight props to reduce image size after pick image.

or

you can use https://github.com/ivpusic/react-native-image-crop-picker for pick image. and use compressImageMaxWidth and compressImageMaxHeight props for reduce image size.

I hope it solves the problem.

0
votes

I used

react-native-image-crop-picker react-native-image-picker

and did reduce the size of the image and did upload to firebase using base64 => ...putString(Image64, 'base64');...

**The problem was **that when needed to upload 2 images with different sizes firebase upload went wrong. and gave me this

Can currently only create a Blob from other Blobs

I was using blobs before and had the same response to uploading 2 different images

anyone knows what can I do besides uploading the same size and then using firebase functions to resize the images by name?