Skip to content

Commit

Permalink
update containers controller
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfaron committed Sep 27, 2023
1 parent 32a13d4 commit 234fe41
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ projects/aas-server/src/app/routes
.DS_Store
Thumbs.db
.VSCodeCounter
aas-server-config.json
2 changes: 1 addition & 1 deletion projects/aas-portal/src/app/aas/aas-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class AASApiService {
*/
public putDocument(document: AASDocument): Observable<string[]> {
const formData = new FormData();
formData.append('content', JSON.stringify(document.content))
formData.append('content', new Blob([JSON.stringify(document.content)]));
return this.http.put<string[]>(
`/api/v1/containers/${encodeBase64Url(document.container)}/documents/${encodeBase64Url(document.id)}`,
formData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<string[]> {
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();
}
Expand Down

0 comments on commit 234fe41

Please sign in to comment.