feat: enable S3 video uploads and update related configurations

- 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
This commit is contained in:
yusufipk
2026-05-27 17:04:39 +02:00
parent b6de3a29aa
commit 4bf6e821af
57 changed files with 2707 additions and 436 deletions
+23 -5
View File
@@ -1,5 +1,6 @@
import 'dotenv/config';
import { ensureR2BucketExists, R2_BUCKET_NAME } from '@/lib/r2';
import { ensureR2BucketExists, ensureR2UploadCors, R2_BUCKET_NAME, r2Client } from '@/lib/r2';
import { isS3VideoUploadsEnabled } from '@/lib/feature-flags';
import { logError } from '@/lib/logger';
const shouldCreateBucket = /^(1|true|yes|on)$/i.test(
@@ -15,9 +16,26 @@ async function main() {
console.log(`Ensuring object storage bucket exists: ${R2_BUCKET_NAME}`);
await ensureR2BucketExists();
console.log(`Bucket is ready: ${R2_BUCKET_NAME}`);
if (isS3VideoUploadsEnabled()) {
try {
const origins = await ensureR2UploadCors();
console.log(`Configured upload CORS for origins: ${origins.join(', ')}`);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.warn(
`Skipping automatic bucket CORS setup (${message}). ` +
'If direct S3 uploads fail in the browser, configure bucket CORS manually.'
);
}
}
}
main().catch((error) => {
logError('Self-host bootstrap failed:', error);
process.exit(1);
});
main()
.catch((error) => {
logError('Self-host bootstrap failed:', error);
process.exit(1);
})
.finally(() => {
r2Client.destroy();
});