diff --git a/backend/src/files/files.controller.ts b/backend/src/files/files.controller.ts index a1490d2a..f4fa86e1 100644 --- a/backend/src/files/files.controller.ts +++ b/backend/src/files/files.controller.ts @@ -6,11 +6,11 @@ import { AuthroizedRequest } from "src/utils/types/req.type"; import { CreateUploadPresignedUrlDto } from "./dto/create-upload-url.dto"; import { Public } from "src/utils/decorators/auth.decorator"; -@ApiBearerAuth() @Controller("files") export class FilesController { constructor(private filesService: FilesService) {} + @Public() @Post("") @ApiOperation({ summary: "Create Presigned URL for Upload", @@ -19,12 +19,10 @@ export class FilesController { @ApiBody({ type: CreateUploadPresignedUrlDto }) @ApiResponse({ type: CreateUploadPresignedUrlResponse }) async createUploadPresignedUrl( - @Req() req: AuthroizedRequest, @Body() createUploadPresignedUrlDto: CreateUploadPresignedUrlDto ): Promise { return { url: await this.filesService.createUploadPresignedUrl( - req.user.id, createUploadPresignedUrlDto.workspaceId ), }; diff --git a/backend/src/files/files.service.ts b/backend/src/files/files.service.ts index 951f33ad..eb15019b 100644 --- a/backend/src/files/files.service.ts +++ b/backend/src/files/files.service.ts @@ -18,19 +18,14 @@ export class FilesService { this.s3Client = new S3Client(); } - async createUploadPresignedUrl(userId: string, workspaceId: string) { + async createUploadPresignedUrl(workspaceId: string) { let workspace: Workspace; try { - const userWorkspace = await this.prismaService.userWorkspace.findFirstOrThrow({ + workspace = await this.prismaService.workspace.findFirstOrThrow({ where: { - userId, - workspaceId, - }, - select: { - workspace: true, + id: workspaceId, }, }); - workspace = userWorkspace.workspace; } catch (e) { throw new UnauthorizedException(); }