fix file upload

This commit is contained in:
Peter Maquiran
2024-01-17 15:11:31 +01:00
parent 26526a8d64
commit be60b13d5d
3 changed files with 45 additions and 24 deletions
@@ -12,16 +12,33 @@ export class SocketConnectionMCRService {
connect() { connect() {
// console.log("SocketConnectionMCRService")
var connection = new signalR.HubConnectionBuilder() var connection = new signalR.HubConnectionBuilder()
.withUrl("https://gdcmapi-dev.dyndns.info/FileHub", { .withUrl("https://gdcmapi-dev.dyndns.info/FileHub", {
accessTokenFactory: () => SessionStore.user.Authorization accessTokenFactory: () => SessionStore.user.Authorization
}).configureLogging(signalR.LogLevel.Information) }).configureLogging(signalR.LogLevel.Information)
.build() .build();
connection.on("ReceiveMessage", (message) => { connection.on("ReceiveMessage", (message) => {
console.log(message) console.log("ReceiveMessage", message)
}) })
// connection.start()
// .then(() => {
// console.log("SignalR connection started.");
// })
// .catch((error) => {
// console.error("Error starting SignalR connection:", error);
// });
// connection.onclose((error) => {
// console.log("SignalR connection closed:", error);
// });
} }
} }
@@ -163,7 +163,7 @@ export class MiddlewareServiceService {
headers.set('Authorization', 'Bearer ' + SessionStore.user.Authorization); headers.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
//const geturl = environment.apiURL + 'Tasks/DelegateTask'; //const geturl = environment.apiURL + 'Tasks/DelegateTask';
const geturl = environment.apiURL + 'ObjectServer/UploadFiles'; const geturl = environment.apiPCURL + 'FileContent';
let options = { let options = {
headers: headers headers: headers
@@ -175,7 +175,10 @@ export class MiddlewareServiceService {
formData.append("blobFile", blobFile); formData.append("blobFile", blobFile);
formData.append("length", length); formData.append("length", length);
formData.append("index", index.toString()); formData.append("index", index.toString());
formData.append("path", path);
if(path) {
formData.append("path", path);
}
return this.http.post<IuploadFileLK>(`${geturl}`, formData, options) return this.http.post<IuploadFileLK>(`${geturl}`, formData, options)
} }
@@ -85,7 +85,7 @@ export class NewPublicationPage implements OnInit {
this.filecontent = true; this.filecontent = true;
} }
this.SocketConnectionMCRService.connect() // this.SocketConnectionMCRService.connect()
} }
ngOnInit() { ngOnInit() {
@@ -400,14 +400,15 @@ export class NewPublicationPage implements OnInit {
Files: this.seletedContent, Files: this.seletedContent,
} }
this.publication.Files = this.publication.Files.map( e => ({ // this.publication.Files = this.publication.Files.map( e => ({
FileBase64: e.FileBase64, // FileBase64: e.FileBase64,
FileExtension: e.FileExtension, // FileExtension: e.FileExtension,
OriginalFileName: 'foto' // OriginalFileName: 'foto'
})) // }))
//this.publicationFormMV.setDataToFrom(this.publication)
//this.publicationFormMV.uploadVideosFiles()
// this.publicationFormMV.setDataToFrom(this.publication)
// this.publicationFormMV.uploadVideosFiles()
const loader = this.toastService.loading() const loader = this.toastService.loading()
@@ -956,7 +957,7 @@ export class NewPublicationPage implements OnInit {
class UploadFileUseCase { class UploadFileUseCase {
LakefsRepositoryService: CMAPIService = window["CMAPIService"] CMAPIService: CMAPIService = window["CMAPIService"]
constructor() {} constructor() {}
async execute(ChucksManager: ChucksManager): Promise<Result<ChucksManager, ChucksManager>> { async execute(ChucksManager: ChucksManager): Promise<Result<ChucksManager, ChucksManager>> {
@@ -969,7 +970,7 @@ class UploadFileUseCase {
const blob = new Blob([chunk]); const blob = new Blob([chunk]);
const blobFile = new File([blob], "test.mp4", { type: blob.type }); const blobFile = new File([blob], "test.mp4", { type: blob.type });
return await this.LakefsRepositoryService.FileContent({length, path, index, blobFile}) return await this.CMAPIService.FileContent({length, path, index, blobFile})
} }
if(!ChucksManager.hasPath()) { if(!ChucksManager.hasPath()) {
@@ -979,7 +980,7 @@ class UploadFileUseCase {
const blob = new Blob([chuck]); const blob = new Blob([chuck]);
const blobFile = new File([blob], "test.mp4", { type: blob.type }); const blobFile = new File([blob], "test.mp4", { type: blob.type });
const uploadRequest = await this.LakefsRepositoryService.FileContent({length, path, index: initIndex, blobFile}) const uploadRequest = await this.CMAPIService.FileContent({length, path, index: initIndex, blobFile})
if(uploadRequest.isOk()) { if(uploadRequest.isOk()) {