diff --git a/src/app/pages/publications/publications.page.ts b/src/app/pages/publications/publications.page.ts
index 7c0d4266f..39f73b349 100644
--- a/src/app/pages/publications/publications.page.ts
+++ b/src/app/pages/publications/publications.page.ts
@@ -238,6 +238,42 @@ export class PublicationsPage implements OnInit {
async onFileSelect(event: any) {
+ const file:File = event.target.files[0];
+
+
+ const chunkSize = 1024 * 1024; // Adjust the chunk size as needed
+ const chunks = [];
+ let offset = 0;
+ let i = 0;
+ let j = 0;
+
+ function count () {
+ j++
+ return j
+ }
+
+ while (offset < file.size) {
+ const chunk = file.slice(offset, offset + chunkSize);
+ const reader = new FileReader();
+
+ reader.onload = async () => {
+
+ const headers = new HttpHeaders()
+ .append('X-File-Name', "fileName")
+ .append('X-File-Extension', "mp4")
+ .append('X-File-Content-Length', i.toString())
+ .append('X-File-Index', count().toString());
+
+ const a = new Uint8Array(reader.result as ArrayBuffer)
+ await this.http.post('http://localhost:3001/upload', a.buffer, { headers, responseType: 'blob' }).toPromise();
+
+
+ };
+ reader.readAsArrayBuffer(chunk);
+ offset += chunkSize;
+ i++;
+ }
+
}
@@ -265,9 +301,6 @@ export class PublicationsPage implements OnInit {
const loader = this.toastService.loading();
try {
await this.publications.DeletePresidentialAction(id).toPromise();
- if(window["refreshPublication"]) {
- window["refreshPublication"]();
- }
this.toastService._successMessage()
} catch (error) {
if(error.status == 0) {
@@ -316,7 +349,7 @@ export class PublicationsPage implements OnInit {
componentProps: {
publicationType: publicationType,
folderId: folderId,
- intent: intent
+ intent: window["sharedContent"]
},
cssClass: 'new-publication modal modal-desktop',
backdropDismiss: false
@@ -329,8 +362,8 @@ export class PublicationsPage implements OnInit {
}
goToPublicationsList(folderId: string) {
- if(this.intent){
- this.AddPublication('2',folderId,this.intent)
+ if(window["sharedContent"]){
+ this.AddPublication('2',folderId,window["sharedContent"])
return
}
if (window.innerWidth < 701) {
diff --git a/src/app/shared/publication/new-publication/new-publication.page.html b/src/app/shared/publication/new-publication/new-publication.page.html
index 2b418047a..507ae0b7f 100644
--- a/src/app/shared/publication/new-publication/new-publication.page.html
+++ b/src/app/shared/publication/new-publication/new-publication.page.html
@@ -53,6 +53,16 @@
X
+
+
+
+
+
+
diff --git a/src/app/shared/publication/new-publication/new-publication.page.ts b/src/app/shared/publication/new-publication/new-publication.page.ts
index bd1ee85d7..5a926db57 100644
--- a/src/app/shared/publication/new-publication/new-publication.page.ts
+++ b/src/app/shared/publication/new-publication/new-publication.page.ts
@@ -23,7 +23,7 @@ import { Filesystem, Directory, Encoding, FilesystemDirectory } from '@capacitor
import { Platform } from '@ionic/angular';
import { Capacitor } from '@capacitor/core';
import { PublicationAttachmentEntity, PublicationFormMV } from '../upload/upload-streaming.service';
-
+import { PublicationFormMVService } from "src/app/shared/publication/upload/publication-form-mv.service"
enum ActionType {
newRapid = "1",
@@ -75,6 +75,7 @@ export class NewPublicationPage implements OnInit {
constructor(
+ PublicationFormMVService: PublicationFormMVService,
public photoService: PhotoService,
private publications: PublicationsService,
private toastService: ToastService,
@@ -452,8 +453,6 @@ export class NewPublicationPage implements OnInit {
e.OriginalFileName = e.chucksManager.path.replace(".mp4", "")
e.FileExtension = "mp4"
}
- this.publicationFormMV.ObjectMergeNotification.socket.commit(e.chucksManager.path)
-
return e
})
@@ -515,7 +514,6 @@ export class NewPublicationPage implements OnInit {
e.Base64 = ""
}
- this.publicationFormMV.ObjectMergeNotification.socket.commit(e.chucksManager.path)
return e
})
diff --git a/src/app/shared/publication/upload/publication-form-mv.service.spec.ts b/src/app/shared/publication/upload/publication-form-mv.service.spec.ts
new file mode 100644
index 000000000..e29f538fa
--- /dev/null
+++ b/src/app/shared/publication/upload/publication-form-mv.service.spec.ts
@@ -0,0 +1,16 @@
+import { TestBed } from '@angular/core/testing';
+
+import { PublicationFormMVService } from './publication-form-mv.service';
+
+describe('PublicationFormMVService', () => {
+ let service: PublicationFormMVService;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({});
+ service = TestBed.inject(PublicationFormMVService);
+ });
+
+ it('should be created', () => {
+ expect(service).toBeTruthy();
+ });
+});
diff --git a/src/app/shared/publication/upload/publication-form-mv.service.ts b/src/app/shared/publication/upload/publication-form-mv.service.ts
new file mode 100644
index 000000000..7fbeee014
--- /dev/null
+++ b/src/app/shared/publication/upload/publication-form-mv.service.ts
@@ -0,0 +1,9 @@
+import { Injectable } from '@angular/core';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class PublicationFormMVService {
+
+ constructor() { }
+}
diff --git a/src/app/shared/publication/upload/upload-streaming.service.ts b/src/app/shared/publication/upload/upload-streaming.service.ts
index f27414270..750dcf4f5 100644
--- a/src/app/shared/publication/upload/upload-streaming.service.ts
+++ b/src/app/shared/publication/upload/upload-streaming.service.ts
@@ -4,7 +4,7 @@ import { ObjectMergeNotification } from 'src/app/services/socket-connection-mcr.
import { CMAPIService } from "src/app/shared/repository/CMAPI/cmapi.service"
import { DomSanitizer } from '@angular/platform-browser';
-const objectMergeNotification = new ObjectMergeNotification()
+
export enum UploadError {
noConnection = 'noConnection',
@@ -192,10 +192,10 @@ export class PublicationFormMV {
private UploadFileUseCase = new UploadFileUseCase()
private form = new PublicationFormModel()
- ObjectMergeNotification = objectMergeNotification
+ ObjectMergeNotification = new ObjectMergeNotification()
constructor() {
- this.ObjectMergeNotification.connect();
+ // this.ObjectMergeNotification.connect();
}
setDataToFrom(data: IPublicationFormModelEntity) {
@@ -218,11 +218,11 @@ export class PublicationFormMV {
PublicationAttachmentEntity.setChunkManger(fileChunks)
PublicationAttachmentEntity.chucksManager.registerOnLastChunk(() => {
+ this.ObjectMergeNotification.socket.commit(PublicationAttachmentEntity.chucksManager.path)
const guid = PublicationAttachmentEntity.chucksManager.path
this.ObjectMergeNotification.subscribe(guid, (data) => {
- // console.log("data", data)
PublicationAttachmentEntity
resolve(true)
})
@@ -437,7 +437,7 @@ export class ChucksManager {
}
registerOnLastChunk(a: Function) {
- this.onSetPath.push(a)
+ this.onSetLastChunk.push(a)
}
registerToUseCaseResponse(a: Function) {