fix publication OrifinalFilename

This commit is contained in:
Peter Maquiran
2024-01-12 12:13:51 +01:00
parent 86b65f3e46
commit 69ee75b039
15 changed files with 187 additions and 122 deletions
+32 -7
View File
@@ -1,19 +1,22 @@
import { Injectable } from '@angular/core';
import { CaptureImageOptions, MediaCapture, MediaFile } from '@awesome-cordova-plugins/media-capture/ngx';
import { Camera, CameraResultType, CameraSource, Photo} from '@capacitor/camera';
import { File } from "@awesome-cordova-plugins/file/ngx"
@Injectable({
providedIn: 'root'
})
export class CameraService {
constructor() { }
constructor(
private mediaCapture: MediaCapture,
private file: File) { }
async takePicture(){
async takePicture() {
return new Promise<Photo>(async (resolve, reject)=>{
const image = await Camera.getPhoto({
quality: 50,
@@ -21,16 +24,38 @@ export class CameraService {
resultType: CameraResultType.Uri,
source: CameraSource.Camera // Camera, Photos or Prompt!
});
if (image) {
resolve(image)
} else {
reject('Error saving image')
}
//this.capturedImage = this.capturedImage;
})
}
async startRecording() {
try {
let options: CaptureImageOptions = { limit: 1}
const data: MediaFile[] = (await this.mediaCapture.captureVideo(options) as any )
const video = data[0]
let dir = video.fullPath.split("/")
dir.pop()
let fromDir = dir.join("/")
let toDir = this.file.dataDirectory
const response = await this.file.copyFile(fromDir, video.name, toDir, video.name )
console.log({response})
} catch(e) {
console.log(e)
}
}
nice() {}
}
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { CameraService } from './camera.service';
describe('CameraService', () => {
let service: CameraService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(CameraService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class CameraService {
constructor() { }
}