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
@@ -67,7 +67,11 @@ export function useDownloadActions({ activeVersion, video }: UseDownloadActionsP
toast.error('Download is disabled for this shared link');
return;
}
if (activeVersion.providerId !== 'bunny' && activeVersion.providerId !== 'direct') {
if (
activeVersion.providerId !== 'bunny' &&
activeVersion.providerId !== 'direct' &&
activeVersion.providerId !== 'r2'
) {
toast.error('This video source does not support direct download');
return;
}
@@ -97,6 +101,11 @@ export function useDownloadActions({ activeVersion, video }: UseDownloadActionsP
}
downloadUrl = `/api/versions/${activeVersion.id}/download?source=${preference}`;
} else if (activeVersion.providerId === 'r2') {
if (!activeVersion.originalUrl.startsWith('/api/upload/video/')) {
throw new Error('Direct download URL is not allowed');
}
downloadUrl = activeVersion.originalUrl;
} else {
downloadUrl = getSafeDirectDownloadUrl(activeVersion.originalUrl);
if (!downloadUrl) {
@@ -113,8 +122,9 @@ export function useDownloadActions({ activeVersion, video }: UseDownloadActionsP
const baseName = sanitizeDownloadFileName(`${video.title} ${versionLabel}`) || 'video';
const a = document.createElement('a');
a.href = downloadUrl;
if (activeVersion.providerId === 'direct') {
a.download = `${baseName}.mp4`;
if (activeVersion.providerId === 'direct' || activeVersion.providerId === 'r2') {
const ext = activeVersion.originalUrl.split('.').pop()?.toLowerCase() || 'mp4';
a.download = `${baseName}.${ext}`;
}
document.body.appendChild(a);
a.click();