Save lmage camera in localstorage

Hello community, I am working with the camera for my application Cordova, and need to do something that had contemplated. You take a photo and publish it but I do that if there is no internet, save the image and upload it when you are online. They may be one or many images that remain in session or saved before uploading. I had thought save base 64 but I have some problems. someone who has done this or I would appreciate some help.

Don’t use base64. You app will crash on lower end devices as the camera will take the photo which will have more than 1 MB in size.

Use FILE_URI and move the photo to a folder and save the photo name in localstorage or some persistent database to use later.

I created an app which used the camera plugin and file plugin to move and save the photos. Its very simple and ngcordova website has good examples for it.

2 Likes

@gaurav_ch Thanks for your answer. When you save the image in a folder you refer to any project folder or a folder directly on the reel device?

@sioesi It depends. If you have to make the image available in another app like image editor or something, it needs to be a local folder on the device accessible by all the apps on the device. If you want the image in your app only, then local app folder will be ideal.

Check the paths available in file plugin. You would need a read and write path.

@gaurav_ch The truth is I’m a little confused.I took the picture, and occupied the FILE_URI saveAlbum true. But the image is not saved in folders.

@sioesi after you take the picture, the plugin gives you the full url of the image location. You need to pass this location to file plugin and move it to a folder.

You need to use both Camera and File plugins together. Just go through these 2 docs:

http://ngcordova.com/docs/plugins/camera/

http://ngcordova.com/docs/plugins/file/

Since, you are already using camera plugin, focus on file plugin.

2 Likes

@gaurav_ch i have tried saving image to gallery from camera and have saved some data in local storage against name of that picture but when ever i select that picture from gallery it comes up with a different name how can i get the title of any image selected from galley so i can pull the data from local storage against that name.

can you tell me how to store images in localstorage in ionic2
I am getting error which says
"cannot find namespace cordova"
Here is my sample code

import { File } from ‘ionic-native’

declare var cordova: any;

@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage {

cameraImage : string;
path : cordova.file.dataDirectory;
constructor(private navCtrl: NavController) {

Hi did you you clear this issue .Please tell me how did you clear this issue if it is cleared