@theoven/storage-imagekit
v0.6.1
Published
ImageKit for Oven — uploads through the storage contract, plus transformation URLs
Downloads
1,565
Maintainers
Readme
@theoven/storage-imagekit
ImageKit for Oven — uploads through the storage contract, plus transformation URLs.
A driver for @theoven/storage, so everything
on ctx.storage works unchanged: upload, download, list, delete.
bun add @theoven/storage @theoven/storage-imagekitUsage
import { storage } from '@theoven/storage'
import { imagekitStorage } from '@theoven/storage-imagekit'
const media = imagekitStorage({
privateKey: process.env.IMAGEKIT_PRIVATE_KEY!,
urlEndpoint: process.env.IMAGEKIT_URL_ENDPOINT!,
})
const app = createApp().use(storage(media))Upload once through ctx.storage, then serve any size from the URL — the reason to use ImageKit
rather than plain object storage:
await ctx.storage.upload('avatars/1.png', file)
media.url('avatars/1.png', { transform: { width: 200, height: 200, format: 'auto' } })
// https://ik.imagekit.io/demo/avatars/1.png?tr=w-200,h-200,f-autoSigned URLs cover the transformation as well as the path, so a client cannot edit tr= to
request a 10,000px render off a signed URL.
Limitations
- No presigned uploads. ImageKit's browser upload is a token/signature triple, not a
PUT-able URL. remove,existsandstatcost an extra lookup — the contract is path-keyed and ImageKit works byfileId.- Uploads are buffered, and paging is offset-based.
Documentation
https://theoven.app/docs/bricks/storage-imagekit/
License
MIT
