Skip to content

Commit

Permalink
Fix: attachements are not loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithmullapudi committed Feb 3, 2025
1 parent 2362a4b commit 20737e9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
28 changes: 28 additions & 0 deletions apps/server/src/modules/attachments/attachments.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,34 @@ export class AttachmentController {
}
}

@Get(':workspaceId/:attachmentId')
@UseGuards(AuthGuard)
async getFileFromGCSForWorkspace(
@Param() attachementRequestParams: AttachmentRequestParams,
@Res() res: Response,
) {
try {
const { signedUrl, contentType } =
await this.attachementService.getFileFromStorageSignedUrl(
attachementRequestParams,
attachementRequestParams.workspaceId,
);

// Set content disposition header with the original filename
res.set({
'Content-Type': contentType,
'Content-Disposition': 'inline',
'Cache-Control': 'public, immutable, max-age=31536000', // Cache for 1 year (effectively infinite)
});

https.get(signedUrl, (stream) => {
stream.pipe(res);
});
} catch (error) {
res.status(404).send('File not found');
}
}

@Get(':attachmentId')
@UseGuards(AuthGuard)
async getFileFromGCS(
Expand Down
3 changes: 3 additions & 0 deletions apps/server/src/modules/attachments/attachments.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { IsOptional, IsString } from 'class-validator';
export class AttachmentRequestParams {
@IsString()
attachmentId: string;

@IsString()
workspaceId: string;
}

export interface ExternalFile {
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/attachments/attachments.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class AttachmentService {
contentType: file.contentType,
});

const publicURL = `${process.env.PUBLIC_ATTACHMENT_URL}/v1/attachment/${workspaceId}/${attachment.id}`;
const publicURL = `${process.env.PUBLIC_ATTACHMENT_URL}/v1/attachment/${attachment.id}`;

return {
url,
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ ul[data-type='taskList'] li[data-checked='true'] > div > p {

.side-issue-view .context-box {
@apply border border-border;
border-radius: 0 !important;
box-shadow: 0px 16px 32px 0px rgba(20, 20, 20, 0.2) !important;
}

.side-issue-view .main-container {
@apply py-2;
padding: 0 !important;
}

.dark .side-issue-view .context-box {
Expand Down

0 comments on commit 20737e9

Please sign in to comment.