@airdraft/media-adapter-files-sdk
v0.1.11
Published
Airdraft media adapter for files-sdk — S3, R2, GCS, Cloudinary, Vercel Blob, and 30+ more
Readme
@airdraft/media-adapter-files-sdk
Media storage adapter for Airdraft that wraps files-sdk v2 providers. Used by @airdraft/plugin-media and Airdraft Cloud for S3-compatible storage, Superfiles, and other provider adapters.
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'
import { s3 } from 'files-sdk/s3'
const files = new Files({
adapter: s3({ bucket: process.env.AWS_S3_BUCKET_NAME! }),
})
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 |
Requires files-sdk >=2.0.0. Provider adapters such as files-sdk-superfiles are installed separately.
Changelog
See CHANGELOG.md.
