mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix file upload
This commit is contained in:
@@ -11,17 +11,34 @@ export class SocketConnectionMCRService {
|
||||
constructor() { }
|
||||
|
||||
connect() {
|
||||
|
||||
|
||||
// console.log("SocketConnectionMCRService")
|
||||
|
||||
var connection = new signalR.HubConnectionBuilder()
|
||||
.withUrl("https://gdcmapi-dev.dyndns.info/FileHub", {
|
||||
accessTokenFactory: () => SessionStore.user.Authorization
|
||||
}).configureLogging(signalR.LogLevel.Information)
|
||||
.build()
|
||||
.build();
|
||||
|
||||
|
||||
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);
|
||||
|
||||
//const geturl = environment.apiURL + 'Tasks/DelegateTask';
|
||||
const geturl = environment.apiURL + 'ObjectServer/UploadFiles';
|
||||
const geturl = environment.apiPCURL + 'FileContent';
|
||||
|
||||
let options = {
|
||||
headers: headers
|
||||
@@ -175,7 +175,10 @@ export class MiddlewareServiceService {
|
||||
formData.append("blobFile", blobFile);
|
||||
formData.append("length", length);
|
||||
formData.append("index", index.toString());
|
||||
formData.append("path", path);
|
||||
|
||||
if(path) {
|
||||
formData.append("path", path);
|
||||
}
|
||||
|
||||
return this.http.post<IuploadFileLK>(`${geturl}`, formData, options)
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ export class NewPublicationPage implements OnInit {
|
||||
this.filecontent = true;
|
||||
}
|
||||
|
||||
this.SocketConnectionMCRService.connect()
|
||||
// this.SocketConnectionMCRService.connect()
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -353,22 +353,22 @@ export class NewPublicationPage implements OnInit {
|
||||
DatePublication: this.publication.DatePublication,
|
||||
Files: this.seletedContent,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
this.publication.Files = this.publication.Files.map( e => ({
|
||||
FileBase64: e.FileBase64,
|
||||
FileExtension: e.FileExtension,
|
||||
OriginalFileName: 'foto'
|
||||
}))
|
||||
|
||||
|
||||
try {
|
||||
|
||||
|
||||
const response = await this.publications.UpdatePublication(this.publication.ProcessId, this.publication).toPromise()
|
||||
|
||||
|
||||
this.httpErroHandle.httpsSucessMessagge('Editar publicação')
|
||||
|
||||
|
||||
this.goBack();
|
||||
|
||||
|
||||
} catch (error) {
|
||||
this.httpErroHandle.httpStatusHandle(error)
|
||||
if (error.status == 404) {
|
||||
@@ -400,14 +400,15 @@ export class NewPublicationPage implements OnInit {
|
||||
Files: this.seletedContent,
|
||||
}
|
||||
|
||||
this.publication.Files = this.publication.Files.map( e => ({
|
||||
FileBase64: e.FileBase64,
|
||||
FileExtension: e.FileExtension,
|
||||
OriginalFileName: 'foto'
|
||||
}))
|
||||
|
||||
// this.publicationFormMV.setDataToFrom(this.publication)
|
||||
// this.publicationFormMV.uploadVideosFiles()
|
||||
// this.publication.Files = this.publication.Files.map( e => ({
|
||||
// FileBase64: e.FileBase64,
|
||||
// FileExtension: e.FileExtension,
|
||||
// OriginalFileName: 'foto'
|
||||
// }))
|
||||
|
||||
//this.publicationFormMV.setDataToFrom(this.publication)
|
||||
//this.publicationFormMV.uploadVideosFiles()
|
||||
|
||||
|
||||
const loader = this.toastService.loading()
|
||||
|
||||
@@ -956,7 +957,7 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
|
||||
class UploadFileUseCase {
|
||||
LakefsRepositoryService: CMAPIService = window["CMAPIService"]
|
||||
CMAPIService: CMAPIService = window["CMAPIService"]
|
||||
constructor() {}
|
||||
async execute(ChucksManager: ChucksManager): Promise<Result<ChucksManager, ChucksManager>> {
|
||||
|
||||
@@ -969,7 +970,7 @@ class UploadFileUseCase {
|
||||
const blob = new Blob([chunk]);
|
||||
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()) {
|
||||
@@ -979,7 +980,7 @@ class UploadFileUseCase {
|
||||
const blob = new Blob([chuck]);
|
||||
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()) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user