Skip to content
Draft
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
17 changes: 8 additions & 9 deletions apps/web/actions/video/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export async function createVideoAndGetUploadUrl({
isScreenshot = false,
isUpload = false,
folderId,
supportsUploadProgress = false,
}: {
videoId?: Video.VideoId;
duration?: number;
Expand All @@ -173,17 +174,14 @@ export async function createVideoAndGetUploadUrl({
isScreenshot?: boolean;
isUpload?: boolean;
folderId?: Folder.FolderId;
supportsUploadProgress?: boolean;
}) {
const user = await getCurrentUser();

if (!user) {
throw new Error("Unauthorized");
}
if (!user) throw new Error("Unauthorized");

try {
if (!userIsPro(user) && duration && duration > 300) {
if (!userIsPro(user) && duration && duration > 300)
throw new Error("upgrade_required");
}

const [customBucket] = await db()
.select()
Expand Down Expand Up @@ -237,9 +235,10 @@ export async function createVideoAndGetUploadUrl({

await db().insert(videos).values(videoData);

await db().insert(videoUploads).values({
videoId: idToUse,
});
if (supportsUploadProgress)
await db().insert(videoUploads).values({
videoId: idToUse,
});

const fileKey = `${user.id}/${idToUse}/${
isScreenshot ? "screenshot/screen-capture.jpg" : "result.mp4"
Expand Down
Loading
Loading