11import { HttpClient } from '@angular/common/http' ;
2- import { Injectable } from '@angular/core' ;
2+ import { Inject , Injectable } from '@angular/core' ;
33import { DomSanitizer } from '@angular/platform-browser' ;
44import { Capacitor } from '@capacitor/core' ;
5+ import { FilesystemPlugin } from '@capacitor/filesystem' ;
56import { TranslocoService } from '@ngneat/transloco' ;
67import { PreviewCamera } from '@numbersprotocol/preview-camera' ;
78import { BehaviorSubject } from 'rxjs' ;
9+ import { FILESYSTEM_PLUGIN } from '../../../shared/capacitor-plugins/capacitor-plugins.module' ;
810import { CaptureService } from '../../../shared/capture/capture.service' ;
911import { ErrorService } from '../../../shared/error/error.service' ;
1012import { blobToBase64 } from '../../../utils/encoding/encoding' ;
@@ -27,7 +29,9 @@ export class CustomCameraService {
2729 private readonly httpClient : HttpClient ,
2830 private readonly captureService : CaptureService ,
2931 private readonly errorService : ErrorService ,
30- private readonly translocoService : TranslocoService
32+ private readonly translocoService : TranslocoService ,
33+ @Inject ( FILESYSTEM_PLUGIN )
34+ private readonly filesystemPlugin : FilesystemPlugin
3135 ) { }
3236
3337 private mediaItemFromFilePath (
@@ -89,6 +93,11 @@ export class CustomCameraService {
8993 return PreviewCamera . stopRecord ( ) . catch ( ( ) => ( { } ) ) ;
9094 }
9195
96+ async removeFile ( filePath : string | undefined ) {
97+ if ( ! filePath ) return ;
98+ await this . filesystemPlugin . deleteFile ( { path : filePath } ) ;
99+ }
100+
92101 private changeGlobalCSSBackgroundToTransparent ( ) {
93102 document . querySelector ( 'body' ) ?. classList . add ( this . globalCSSClass ) ;
94103 document . querySelector ( 'ion-app' ) ?. classList . add ( this . globalCSSClass ) ;
0 commit comments