Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bulk download #542

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pages/api/links/download/bulk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import {
getMimeTypeFromSupportedType,
} from "@/lib/utils/get-content-type";

export const config = {
maxDuration: 180,
};

const s3Client = getS3Client();
const s3Service = new S3DownloadService(s3Client);

Expand Down
10 changes: 10 additions & 0 deletions pages/api/links/download/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default async function handle(
},
document: {
select: {
teamId: true,
versions: {
where: { isPrimary: true },
select: {
Expand Down Expand Up @@ -82,6 +83,15 @@ export default async function handle(
data: { downloadedAt: new Date() },
});

// TODO: team hardcode for special download
if (
view.document!.teamId === "clwt1qwt00000qz39aqra71w6" &&
view.document!.versions[0].type === "sheet"
) {
const downloadUrl = view.document!.versions[0].file;
return res.status(200).json({ downloadUrl });
}

const downloadUrl = await getFile({
type: view.document!.versions[0].storageType,
data: view.document!.versions[0].file,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "Link" ALTER COLUMN "enableFeedback" SET DEFAULT false;

2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ model Link {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
enableNotification Boolean? @default(true) // Optional give user a option to pause/resume the notifications
enableFeedback Boolean? @default(true) // Optional give user a option to enable the reactions toolbar
enableFeedback Boolean? @default(false) // Optional give user a option to enable the reactions toolbar
enableQuestion Boolean? @default(false) // Optional give user a option to enable the question feedback
enableScreenshotProtection Boolean? @default(false) // Optional give user a option to enable the screenshot protection
feedback Feedback?
Expand Down