@airdraft/media-adapter-files-sdk
v0.1.7
Published
Airdraft media adapter for files-sdk — S3, R2, GCS, Cloudinary, Vercel Blob, and 30+ more
Downloads
1,121
Readme
@airdraft/media-adapter-files-sdk
Media storage adapter for Airdraft that wraps the Files SDK to store media on S3-compatible object storage. Used by @airdraft/plugin-media in production / Airdraft Cloud environments.
Installation
npm install @airdraft/media-adapter-files-sdkThe files-sdk package is a peer dependency — install it separately:
npm install files-sdkUsage
import { FilesSdkMediaAdapter } from '@airdraft/media-adapter-files-sdk'
import Files from 'files-sdk'
const files = new Files({ apiKey: process.env.FILES_SDK_API_KEY! })
const adapter = new FilesSdkMediaAdapter({ files })Pass the adapter to withMedia or withAutoMedia:
import { withMedia } from '@airdraft/plugin-media'
const media = withMedia({
adapter,
storageAdapter: contentAdapter,
})Options
| Option | Type | Description |
|---|---|---|
| files | FilesInstance | An initialised Files SDK client instance |
MIME type resolution
When the Files SDK list response does not include type or contentType on file items (which is common for S3 list operations), the adapter falls back to inferring the MIME type from the file extension:
.jpg/.jpeg → image/jpeg · .png → image/png · .webp → image/webp · .gif → image/gif · .svg → image/svg+xml · .pdf → application/pdf · .mp4 → video/mp4 · .webm → video/webm · .mp3 → audio/mpeg
Unknown extensions fall back to application/octet-stream.
Exports
| Export | Description |
|---|---|
| FilesSdkMediaAdapter | The adapter class, implementing MediaAdapter from @airdraft/core |
| FilesSdkMediaAdapterOptions | Options type |
| FilesInstance | Structural interface for the Files SDK client |
Changelog
See CHANGELOG.md.
