0
Hello, I created an application with a simple user registration and storing in the Ionic Storage, however I would like to know how to store an image to be the profile photo of the user
My Provider is like this:
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/map';
import { Storage } from '@ionic/storage';
import { DatePipe } from '@angular/common';
@Injectable()
export class ContactProvider {
constructor(private storage: Storage, private datepipe: DatePipe) { }
public insert(contact: Contact) {
let key = this.datepipe.transform(new Date(), "ddMMyyyyHHmmss");
return this.save(key, contact);
}
public update(key: string, contact: Contact) {
return this.save(key, contact);
}
private save(key: string, contact: Contact) {
return this.storage.set(key, contact);
}
public remove(key: string) {
return this.storage.remove(key);
}
public getAll() {
let contacts: ContactList[] = [];
return this.storage.forEach((value: Contact, key: string, iterationNumber: Number) => {
let contact = new ContactList();
contact.key = key;
contact.contact = value;
contacts.push(contact);
})
.then(() => {
return Promise.resolve(contacts);v b
})
.catch((error) => {
return Promise.reject(error);
});
}
}
export class Contact {
name: string;
lastname: string;
password: string;
phone: number;
birth: Date;
active: boolean;
}
export class ContactList {
key: string;
contact: Contact;
}
In the Store you don’t need to save the image, but the URL of where it is inside the gallery on your device. That’s what you want?
– viana
either that or replicate the image to a folder created by the APP so that the user can move the image.
– Ricardo Martani Stancatti