From 234fe41e806f8e055967d99f550b73b333eae264 Mon Sep 17 00:00:00 2001 From: Ralf Aron Date: Wed, 27 Sep 2023 06:54:11 +0200 Subject: [PATCH] update containers controller --- .gitignore | 1 + projects/aas-portal/src/app/aas/aas-api.service.ts | 2 +- .../src/app/controller/containers-controller.ts | 8 +++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 583237fb..2b71baf8 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ projects/aas-server/src/app/routes .DS_Store Thumbs.db .VSCodeCounter +aas-server-config.json diff --git a/projects/aas-portal/src/app/aas/aas-api.service.ts b/projects/aas-portal/src/app/aas/aas-api.service.ts index e271ffc5..179acc8e 100644 --- a/projects/aas-portal/src/app/aas/aas-api.service.ts +++ b/projects/aas-portal/src/app/aas/aas-api.service.ts @@ -36,7 +36,7 @@ export class AASApiService { */ public putDocument(document: AASDocument): Observable { const formData = new FormData(); - formData.append('content', JSON.stringify(document.content)) + formData.append('content', new Blob([JSON.stringify(document.content)])); return this.http.put( `/api/v1/containers/${encodeBase64Url(document.container)}/documents/${encodeBase64Url(document.id)}`, formData); diff --git a/projects/aas-server/src/app/controller/containers-controller.ts b/projects/aas-server/src/app/controller/containers-controller.ts index ba00fd3e..3b1c1a5c 100644 --- a/projects/aas-server/src/app/controller/containers-controller.ts +++ b/projects/aas-server/src/app/controller/containers-controller.ts @@ -7,7 +7,8 @@ *****************************************************************************/ import { inject, injectable } from 'tsyringe'; -import { Body, Delete, Get, OperationId, Path, Post, Put, Queries, Route, Security, Tags, UploadedFiles } from 'tsoa'; +import fs from 'fs'; +import { Body, Delete, Get, OperationId, Path, Post, Put, Queries, Route, Security, Tags, UploadedFile, UploadedFiles } from 'tsoa'; import { AASDocument, aas } from 'common'; import { AASProvider } from '../aas-provider/aas-provider.js'; @@ -196,11 +197,12 @@ export class ContainersController extends ControllerBase { public async updateDocument( @Path() url: string, @Path() id: string, - @Body() content: aas.Environment + @UploadedFile() content: Express.Multer.File ): Promise { try { this.logger.start('updateDocument'); - return await this.aasProvider.updateDocumentAsync(decodeBase64Url(url), decodeBase64Url(id), content); + const env: aas.Environment = JSON.parse((await fs.promises.readFile(content.path)).toString()); + return await this.aasProvider.updateDocumentAsync(decodeBase64Url(url), decodeBase64Url(id), env); } finally { this.logger.stop(); }