1
1
import { HttpClient } from '@angular/common/http' ;
2
- import { Injectable } from '@angular/core' ;
2
+ import { Inject , Injectable } from '@angular/core' ;
3
3
import { DomSanitizer } from '@angular/platform-browser' ;
4
4
import { Capacitor } from '@capacitor/core' ;
5
+ import { FilesystemPlugin } from '@capacitor/filesystem' ;
5
6
import { TranslocoService } from '@ngneat/transloco' ;
6
7
import { PreviewCamera } from '@numbersprotocol/preview-camera' ;
7
8
import { BehaviorSubject } from 'rxjs' ;
9
+ import { FILESYSTEM_PLUGIN } from '../../../shared/capacitor-plugins/capacitor-plugins.module' ;
8
10
import { CaptureService } from '../../../shared/capture/capture.service' ;
9
11
import { ErrorService } from '../../../shared/error/error.service' ;
10
12
import { blobToBase64 } from '../../../utils/encoding/encoding' ;
@@ -27,7 +29,9 @@ export class CustomCameraService {
27
29
private readonly httpClient : HttpClient ,
28
30
private readonly captureService : CaptureService ,
29
31
private readonly errorService : ErrorService ,
30
- private readonly translocoService : TranslocoService
32
+ private readonly translocoService : TranslocoService ,
33
+ @Inject ( FILESYSTEM_PLUGIN )
34
+ private readonly filesystemPlugin : FilesystemPlugin
31
35
) { }
32
36
33
37
private mediaItemFromFilePath (
@@ -89,6 +93,11 @@ export class CustomCameraService {
89
93
return PreviewCamera . stopRecord ( ) . catch ( ( ) => ( { } ) ) ;
90
94
}
91
95
96
+ async removeFile ( filePath : string | undefined ) {
97
+ if ( ! filePath ) return ;
98
+ await this . filesystemPlugin . deleteFile ( { path : filePath } ) ;
99
+ }
100
+
92
101
private changeGlobalCSSBackgroundToTransparent ( ) {
93
102
document . querySelector ( 'body' ) ?. classList . add ( this . globalCSSClass ) ;
94
103
document . querySelector ( 'ion-app' ) ?. classList . add ( this . globalCSSClass ) ;
0 commit comments