mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 17:46:06 +00:00
- Added support for self-hosted S3 video uploads with new environment variables: OPENFRAME_ENABLE_S3_VIDEO_UPLOADS and OPENFRAME_MAX_VIDEO_UPLOAD_BYTES. - Updated .env.example and .env.docker.example to reflect new configuration options. - Enhanced Content Security Policy to include origins for S3-compatible storage. - Updated dependencies for AWS SDK to support new features. - Refactored upload logic to accommodate both Bunny and S3 upload providers. - Updated documentation to clarify the usage of direct uploads and S3 configurations. - Closes #11
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import { db } from '@/lib/db';
|
|
|
|
export type CreateR2UploadSessionInput = {
|
|
userId: string;
|
|
projectId: string;
|
|
billedUserId: string;
|
|
objectKey: string;
|
|
thumbnailObjectKey: string;
|
|
declaredSizeBytes: bigint;
|
|
contentType: string;
|
|
reservationId: string | null;
|
|
uploadJti: string;
|
|
expiresAt: Date;
|
|
};
|
|
|
|
export async function createR2UploadSession(input: CreateR2UploadSessionInput) {
|
|
return db.videoUploadSession.create({
|
|
data: {
|
|
userId: input.userId,
|
|
projectId: input.projectId,
|
|
billedUserId: input.billedUserId,
|
|
objectKey: input.objectKey,
|
|
thumbnailObjectKey: input.thumbnailObjectKey,
|
|
declaredSizeBytes: input.declaredSizeBytes,
|
|
contentType: input.contentType,
|
|
reservationId: input.reservationId,
|
|
uploadJti: input.uploadJti,
|
|
expiresAt: input.expiresAt,
|
|
},
|
|
});
|
|
}
|
|
|
|
export async function cancelR2UploadSession(sessionId: string) {
|
|
return db.videoUploadSession.updateMany({
|
|
where: {
|
|
id: sessionId,
|
|
status: 'INITIATED',
|
|
expiresAt: { gt: new Date() },
|
|
},
|
|
data: {
|
|
status: 'CANCELLED',
|
|
consumedAt: new Date(),
|
|
},
|
|
});
|
|
}
|