Lumen & Gesso / website · lumengesso.com / app / lib / review-photo-storage.ts
| 1 | import 'server-only'; |
| 2 | import { getCloudflareContext } from '@opennextjs/cloudflare'; |
| 3 | |
| 4 | type ReviewPhotoBucket = { |
| 5 | get(key: string): Promise<{ body: ReadableStream<Uint8Array> } | null>; |
| 6 | put(key: string, body: Uint8Array, options: { httpMetadata: { contentType: string } }): Promise<unknown>; |
| 7 | delete(key: string): Promise<void>; |
| 8 | }; |
| 9 | |
| 10 | export function reviewPhotoBucket(): ReviewPhotoBucket { |
| 11 | const { REVIEW_PHOTOS } = getCloudflareContext().env as { REVIEW_PHOTOS?: ReviewPhotoBucket }; |
| 12 | if (!REVIEW_PHOTOS) throw new Error('Review photo storage binding is missing.'); |
| 13 | return REVIEW_PHOTOS; |
| 14 | } |