UNPKG

@adonis-agora/media

Version:

Media-library for AdonisJS — owner collections (MIME whitelist, single-file replace, ordering), image conversions (eager/lazy), pluggable content transformers (HLS video via mediabunny, metadata probe, image blur-up placeholder), and column attachments, a

22 lines • 992 B
import { UploadNotSupportedError } from './errors.js'; /** * Decide whether an upload flows through the backend (`proxy` — the app streams bytes to the disk) * or straight to the disk (`direct` — the app issues presigned multipart part URLs and the client * uploads to S3 itself). * * - `proxy`: always allowed (every disk can accept bytes through `put`/`putStream`). * - `direct`: requires a multipart-capable disk; otherwise throws {@link UploadNotSupportedError}. * - `auto`: `direct` when the disk is multipart-capable, else `proxy`. */ export function resolveUploadMode(levels, directCapable, diskName = 'disk') { const mode = levels.perCall ?? levels.perDisk ?? levels.global ?? 'auto'; if (mode === 'proxy') return 'proxy'; if (mode === 'direct') { if (!directCapable) throw new UploadNotSupportedError(diskName); return 'direct'; } return directCapable ? 'direct' : 'proxy'; } //# sourceMappingURL=upload_mode.js.map