xfumihiro / react-native-image-to-base64

React Native module to get Image's base64 string
MIT License
78 stars 37 forks source link

Callback function crashes #3

Closed Psiiirus closed 7 months ago

Psiiirus commented 8 years ago

Hi, I tried to use this module but unfortunately I cant get it work. Any clue whats wrong? :/

"react-native": "0.35.0"

console.log("do uploadPicture",this.state.capturedImage.path,RNImageToBase64 ); // works fine
RNImageToBase64.getBase64String(this.state.capturedImage.path, function(err, imageBase64) {
... 
});

Xcode error

bildschirmfoto 2016-10-21 um 01 02 55
Psiiirus commented 8 years ago

Do i need to set special privacy settings?!

Psiiirus commented 8 years ago

I think i got it.

It seems that ALAssetsLibrary is deprecated and removed since SDK 10.0 like all other ALAsset related libs.

Unfortunately I don't really get how to change it because of not having any objective-c background

´´´ ... NS_CLASS_DEPRECATED_IOS(4_0, 9_0, "Use PHPhotoLibrary from the Photos framework instead") @interface ALAssetsLibrary : NSObject { ...

// Returns an ALAssetRepresentation object for the default representation of the ALAsset

´´´

Would be awesome if you can have a look @xfumihiro .

cherniv commented 8 years ago

Right, it is not possible to use this library now :( ..

joypatel04 commented 8 years ago

@MM-Psiiirus Is there any updates? you solved it or something else you are using?

joypatel04 commented 8 years ago

@xfumihiro Can you please take a look at it and give an update? Is this issue still there or not?

dyguests commented 8 years ago

same issue.OTL. is there anyway else? :(

Psiiirus commented 8 years ago

in my case I needed a base64 captured camera image so i just chose another camera bundle which provided an asset-uri and a base64. :/

Psiiirus commented 8 years ago

@dyguests , @joypatel04 i just came along the ImageStore...maybe this can help you solve the problem without this npm-package

https://facebook.github.io/react-native/docs/imagestore.html#getbase64fortag

ImageStore.getBase64ForTag("file://" +imageURI.uri,(data) =>
      {
        console.log('getBase64ForTag',data);
        this.setState({
          ...this.state,
          capturedImage: {data,uri: imageURI.uri },
          isLoading: false
        });
      },(e) => {
          console.log('getBase64ForTag-error',e);
        this.setState({
          ...this.state,
          isLoading: false
        });
      });
muszu commented 7 years ago

For me (iOS 10) ImageStore don't work. I created PR where I handle only local files, but I'm going to make it work with normal url and add handling errors.

minhphung210 commented 6 years ago

you can use https://github.com/itinance/react-native-fs

  RNFS.readFile(path, 'base64')
  .then((data) => console.log(data))
  .catch((err) => console.log(err)); 
});