File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
docs/angular/your-first-app
versioned_docs/version-v7/angular/your-first-app Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ export class PhotoService {
119119 quality: 100 ,
120120 });
121121
122+ // Save the picture and add it to photo collection
122123 const savedImageFile = await this .savePicture (capturedPhoto );
123124
124125 this .photos .unshift (savedImageFile );
@@ -166,6 +167,17 @@ export class PhotoService {
166167 // Retrieve cached photo array data
167168 const { value : photoList } = await Preferences .get ({ key: this .PHOTO_STORAGE });
168169 this .photos = (photoList ? JSON .parse (photoList ) : []) as UserPhoto [];
170+
171+ for (let photo of this .photos ) {
172+ // Read each saved photo's data from the Filesystem
173+ const readFile = await Filesystem .readFile ({
174+ path: photo .filepath ,
175+ directory: Directory .Data ,
176+ });
177+
178+ // Web platform only: Load the photo as base64 data
179+ photo .webviewPath = ` data:image/jpeg;base64,${readFile .data } ` ;
180+ }
169181 }
170182}
171183
Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ export class PhotoService {
119119 quality: 100 ,
120120 });
121121
122+ // Save the picture and add it to photo collection
122123 const savedImageFile = await this .savePicture (capturedPhoto );
123124
124125 this .photos .unshift (savedImageFile );
@@ -166,6 +167,17 @@ export class PhotoService {
166167 // Retrieve cached photo array data
167168 const { value : photoList } = await Preferences .get ({ key: this .PHOTO_STORAGE });
168169 this .photos = (photoList ? JSON .parse (photoList ) : []) as UserPhoto [];
170+
171+ for (let photo of this .photos ) {
172+ // Read each saved photo's data from the Filesystem
173+ const readFile = await Filesystem .readFile ({
174+ path: photo .filepath ,
175+ directory: Directory .Data ,
176+ });
177+
178+ // Web platform only: Load the photo as base64 data
179+ photo .webviewPath = ` data:image/jpeg;base64,${readFile .data } ` ;
180+ }
169181 }
170182}
171183
You can’t perform that action at this time.
0 commit comments