mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
fix open shared publication folder
This commit is contained in:
@@ -18,10 +18,11 @@ import { SocketConnectionMCRService } from "src/app/services/socket-connection-m
|
||||
import { CMAPIService } from '../../repository/CMAPI/cmapi.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { CaptureImageOptions, MediaCapture } from '@awesome-cordova-plugins/media-capture/ngx';
|
||||
import { Filesystem, FilesystemDirectory } from '@capacitor/filesystem';
|
||||
import { Directory, Filesystem, FilesystemDirectory } from '@capacitor/filesystem';
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { PublicationAttachmentEntity, PublicationFormMV } from '../upload/upload-streaming.service';
|
||||
import { PublicationFormMVService } from "src/app/shared/publication/upload/publication-form-mv.service"
|
||||
import { VideoconvertService } from 'src/app/services/videoconvert.service';
|
||||
|
||||
enum ActionType {
|
||||
newRapid = "1",
|
||||
@@ -86,6 +87,7 @@ export class NewPublicationPage implements OnInit {
|
||||
private MiddlewareServiceService: MiddlewareServiceService,
|
||||
private LakefsRepositoryService: LakefsRepositoryService,
|
||||
private SocketConnectionMCRService: SocketConnectionMCRService,
|
||||
private videoconvertService: VideoconvertService
|
||||
) {
|
||||
this.publicationTitle = 'Nova Publicação';
|
||||
}
|
||||
@@ -727,29 +729,11 @@ export class NewPublicationPage implements OnInit {
|
||||
data.forEach(async element => {
|
||||
this.filesSizeSum = this.filesSizeSum + element.size
|
||||
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
|
||||
const savedFile = await Filesystem.copy({
|
||||
from: element.fullPath, // directory prop removed, Capacitor parses filename for us
|
||||
to: "video.mp4",
|
||||
toDirectory: FilesystemDirectory.Data
|
||||
});
|
||||
console.log(savedFile.uri)
|
||||
Filesystem.readFile({ path: savedFile.uri })
|
||||
|
||||
.then(async (content) => {
|
||||
this.filecontent = true;
|
||||
console.log('', content)
|
||||
let fileObject = new PublicationAttachmentEntity({
|
||||
base64: content.data,
|
||||
extension: 'mp4',
|
||||
OriginalFileName: 'record',
|
||||
FileType: 'video'
|
||||
|
||||
}
|
||||
)
|
||||
this.publicationFormMV.form.Files.push(fileObject)
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
if(this.platform.is('ios'))
|
||||
this.recordevideoIos(element.fullPath)
|
||||
} else {
|
||||
this.recordVideoPc(element.fullPath)
|
||||
|
||||
if (this.publicationFormMV.form.Files.length === 0)
|
||||
this.filesSizeSum = 0
|
||||
|
||||
@@ -771,6 +755,65 @@ export class NewPublicationPage implements OnInit {
|
||||
if (this.platform.is('desktop'))
|
||||
return true;
|
||||
}
|
||||
|
||||
async recordevideoIos(fullPath) {
|
||||
try {
|
||||
const directory = await Filesystem.getUri({
|
||||
directory: Directory.Cache,
|
||||
path: '',
|
||||
});
|
||||
|
||||
this.videoconvertService.convertVideo(fullPath,directory.uri,'mp4');
|
||||
|
||||
Filesystem.readFile({ path: `${directory.uri}output.mp4`})
|
||||
|
||||
.then(async (content) => {
|
||||
this.filecontent = true;
|
||||
console.log('', content)
|
||||
let fileObject = new PublicationAttachmentEntity({
|
||||
base64: content.data,
|
||||
extension: 'mp4',
|
||||
OriginalFileName: 'record',
|
||||
FileType: 'video'
|
||||
|
||||
}
|
||||
)
|
||||
this.publicationFormMV.form.Files.push(fileObject)
|
||||
})
|
||||
.catch((erro) => console.error('read converted video erro ', erro));
|
||||
} catch (error) {
|
||||
console.log('record video ios erro, ', error)
|
||||
}
|
||||
}
|
||||
|
||||
async recordVideoPc(fullPath) {
|
||||
try {
|
||||
const savedFile = await Filesystem.copy({
|
||||
from: fullPath, // directory prop removed, Capacitor parses filename for us
|
||||
to: "video.mp4",
|
||||
toDirectory: FilesystemDirectory.Data
|
||||
});
|
||||
console.log(savedFile.uri)
|
||||
Filesystem.readFile({ path: savedFile.uri })
|
||||
|
||||
.then(async (content) => {
|
||||
this.filecontent = true;
|
||||
console.log('', content)
|
||||
let fileObject = new PublicationAttachmentEntity({
|
||||
base64: content.data,
|
||||
extension: 'mp4',
|
||||
OriginalFileName: 'record',
|
||||
FileType: 'video'
|
||||
|
||||
}
|
||||
)
|
||||
this.publicationFormMV.form.Files.push(fileObject)
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user