Skip to content

Commit

Permalink
Change file upload endpoint to public
Browse files Browse the repository at this point in the history
  • Loading branch information
devleejb committed Feb 8, 2024
1 parent a629a6d commit dab9499
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
4 changes: 1 addition & 3 deletions backend/src/files/files.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -19,12 +19,10 @@ export class FilesController {
@ApiBody({ type: CreateUploadPresignedUrlDto })
@ApiResponse({ type: CreateUploadPresignedUrlResponse })
async createUploadPresignedUrl(
@Req() req: AuthroizedRequest,
@Body() createUploadPresignedUrlDto: CreateUploadPresignedUrlDto
): Promise<CreateUploadPresignedUrlResponse> {
return {
url: await this.filesService.createUploadPresignedUrl(
req.user.id,
createUploadPresignedUrlDto.workspaceId
),
};
Expand Down
11 changes: 3 additions & 8 deletions backend/src/files/files.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit dab9499

Please sign in to comment.