[Save To Gallery] JS error

[Save To Gallery] JS error

  
Forge Component
(3)
Published on 8 May by leonardo.fernandes
3 votes
Published on 8 May by leonardo.fernandes

Hi i got the javascript error, "data.replace is not a function"

any fixed?


thanks

Could you tell me which operating system are you trying it on?

leonardo.fernandes wrote:

Could you tell me which operating system are you trying it on?


try in on android 8 oreo, i saw the github source it just normal javascript replace, not sure why it getting this error

I couldn't reproduce the same issue with Android Nougat.

If you're taking pictures from the camera and saving them to the gallery using this plugin, then I think you don't even need it on Android. Android saves all photos taken with the camera to the gallery automatically. Could you please check if in Oreo is any different?

If that's the case, then you could remove this plugin altogether. Otherwise, please share your application so I can try to reproduce the problem.

leonardo.fernandes wrote:

I couldn't reproduce the same issue with Android Nougat.

If you're taking pictures from the camera and saving them to the gallery using this plugin, then I think you don't even need it on Android. Android saves all photos taken with the camera to the gallery automatically. Could you please check if in Oreo is any different?

If that's the case, then you could remove this plugin altogether. Otherwise, please share your application so I can try to reproduce the problem.

Hey

I tested on the android oreo and me it is not working
gives me error without client action SaveMediaToGallery

tks

João, thanks for the effort, but I don't have an Oreo device.

Have you read my previous post? I suggest that you might not even need this component at all. Android devices automatically save all photos taken by the camera, so there's no need to use a plugin to save it to the gallery. I also ask you to share your application, so I can try to reproduce the same problem with my Android Nougat.

Hi Leonardo, my apps take picture using camera preview plugins the result is base64 data, n this plugin not store it on the user gallery, thats why i use this plugin to save the img to user gallery, 

I was testing using the standard Upload control. That must be why I couldn't reproduce the issue.

Can you please share some code with how you're using the camera preview and the save to gallery? I tried to guess once how you're using this component, and failed. I don't want to take another guess.

well camera preview basically give me the base64 image, 

i then convert it to binary

after got the imagebinary i do this

saveImageToGallery expect a binary input parameter, so i pass that imagebinary to the funtion,

i used the imageBinary in other place as well, it work ok, so the imagebinary should be correct.

Hello ari.

I'm not sure how you're using CameraPreview plugin. I'm assuming that's the plugin you're using. I tried using it on Android and got an error: CameraPreview.setOnPictureTakenHandler is not a function.

I read the documentation and it seems that the plugin only works for iOS.


I really want to help you, but if you don't share source code that reproduces the problem, it just wastes our time. I'm certain that, if you had provided me an example in your first post, I would have already given you a solution.

Hi Leonardo, 

Sorry for that, 

actually i create my own camera preview based on this github

https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview

when i take picture i do this:

CameraPreview.takePicture(
    {width:$parameters.Width, height:$parameters.Height, quality: $parameters.Quality}, 
    function(picture) {
        CameraPreview.stopCamera();
        var imgcnt = document.getElementById($parameters.ImgId);
        var outlinecnt = document.getElementById($parameters.OutlineId); 
        outlinecnt.style.display = "none";
        imgcnt.src = "data:image/jpeg;base64,"+picture;
        imgcnt.style.display = "block";
        $actions.OnTakePictureFinished(picture); 
    }
);

insude OnTakePictureFinished action i get the base64 data and pass in to your plugin,

hopefully this help.

thanks for your reply leonardo.

Could you attach your plugin to this thread? I think that's essential if you want me to reproduce the issue.

Have you tried passing "data:image/jpeg;base64,"+picture to the OnTakePictureFinished? SaveToGallery is expecting the data URL to be well-formed.

Ari, were you able to overcome this problem? If so, how did you solve it, and did you find out what was causing it?

Thanks.