mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
done chunk upload
This commit is contained in:
@@ -12,7 +12,6 @@ export enum UploadError {
|
||||
|
||||
export type IOUploadError = "noConnection" | "slow"
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -34,21 +33,7 @@ class UploadFileUseCase {
|
||||
const base64 = await PublicationAttachmentEntity.chucksManager.chunks.getChunks(index)
|
||||
|
||||
|
||||
if(index == 2) {
|
||||
const base1 = await PublicationAttachmentEntity.chucksManager.chunks.getChunks(2)
|
||||
|
||||
// Get the video element from the DOM
|
||||
const videoElement: any = document.getElementById("yourVideoElementId");
|
||||
|
||||
// Set the src attribute of the video element to the blob URL
|
||||
videoElement.src = "data:video/mp4;base64,"+ base1 + base64 ;
|
||||
|
||||
// Optionally, you can also set other attributes or play the video
|
||||
videoElement.controls = true; // Add controls for play, pause, etc.
|
||||
videoElement.play(); // Auto-play the vid
|
||||
}
|
||||
|
||||
const uploadRequest = this.CMAPIService.FileContent({length, path: PublicationAttachmentEntity.chucksManager.path, index, blobFile: base64})
|
||||
const uploadRequest = this.CMAPIService.FileContent({length, path: PublicationAttachmentEntity.chucksManager.path, index, base64})
|
||||
|
||||
uploadRequest.then((uploadRequest) => {
|
||||
if(uploadRequest.isOk()) {
|
||||
@@ -59,21 +44,21 @@ class UploadFileUseCase {
|
||||
return uploadRequest;
|
||||
}
|
||||
|
||||
// if(!PublicationAttachmentEntity.chucksManager.hasPath()) {
|
||||
// const guidRequest = await this.CMAPIService.RequestUpload()
|
||||
if(!PublicationAttachmentEntity.chucksManager.hasPath()) {
|
||||
const guidRequest = await this.CMAPIService.RequestUpload()
|
||||
|
||||
// if(guidRequest.isOk()) {
|
||||
// path = guidRequest.value+".mp4"
|
||||
// PublicationAttachmentEntity.chucksManager.setPath(path)
|
||||
// } else {
|
||||
// const pingRequest = await this.CMAPIService.ping()
|
||||
// if( pingRequest.isErr()) {
|
||||
// return resolve(err(UploadError.noConnection))
|
||||
// } else {
|
||||
// return resolve(err(UploadError.slow))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if(guidRequest.isOk()) {
|
||||
path = guidRequest.value+".mp4"
|
||||
PublicationAttachmentEntity.chucksManager.setPath(path)
|
||||
} else {
|
||||
const pingRequest = await this.CMAPIService.ping()
|
||||
if( pingRequest.isErr()) {
|
||||
return resolve(err(UploadError.noConnection))
|
||||
} else {
|
||||
return resolve(err(UploadError.slow))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const allRequest: Promise<any>[] = []
|
||||
let connection = true
|
||||
@@ -219,14 +204,13 @@ export class PublicationFormMV {
|
||||
|
||||
if(!PublicationAttachmentEntity.hasChunkManger) {
|
||||
const fileBlob = PublicationAttachmentEntity.blobFile;
|
||||
const fileChunks = new Chunks({chunkSize: 70 })
|
||||
const fileChunks = new Chunks({chunkSize: 1024 })
|
||||
fileChunks.setFile(fileBlob)
|
||||
|
||||
PublicationAttachmentEntity.setChunkManger(fileChunks)
|
||||
|
||||
PublicationAttachmentEntity.chucksManager.registerOnLastChunk(() => {
|
||||
|
||||
console.log("last chunk ===============================================")
|
||||
const guid = PublicationAttachmentEntity.chucksManager.path
|
||||
|
||||
this.ObjectMergeNotification.subscribe(guid, (data) => {
|
||||
|
||||
Reference in New Issue
Block a user