mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
fix file upload
This commit is contained in:
@@ -11,17 +11,34 @@ export class SocketConnectionMCRService {
|
|||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
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() {
|
||||||
@@ -353,22 +353,22 @@ export class NewPublicationPage implements OnInit {
|
|||||||
DatePublication: this.publication.DatePublication,
|
DatePublication: this.publication.DatePublication,
|
||||||
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'
|
||||||
}))
|
}))
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const response = await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
|
const response = await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
|
||||||
|
|
||||||
this.httpErroHandle.httpsSucessMessagge('Editar publicação')
|
this.httpErroHandle.httpsSucessMessagge('Editar publicação')
|
||||||
|
|
||||||
this.goBack();
|
this.goBack();
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.httpErroHandle.httpStatusHandle(error)
|
this.httpErroHandle.httpStatusHandle(error)
|
||||||
if (error.status == 404) {
|
if (error.status == 404) {
|
||||||
@@ -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.setDataToFrom(this.publication)
|
||||||
// this.publicationFormMV.uploadVideosFiles()
|
//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()) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user