Get Started
To get started using Storage, you need create a bucket first.
Create a bucket
A bucket is a container for objects stored in Storage.
Upload file to bucket
You can upload file to bucket using the SDK or the API directly.
Let’s upload a request body to a bucket using typescript SDK.
import { Storage } from '@urlinks/storage'const storage = new Storage(ctx.env.STORAGE_URL, ctx.env.STORAGE_SECRECT)export default {async fetch(request: Request, ctx: Context): Promise<Response> {ctx.waitUntil(storage.put(crypto.randomUUID(), await request.blob()))// your own handler ...}}
Download file from bucket
You can download file from bucket using the SDK or the API directly.
import { Storage } from '@urlinks/storage'const storage = new Storage(ctx.env.STORAGE_URL, ctx.env.STORAGE_SECRECT)export default {async fetch(request: Request, ctx: Context): Promise<Response> {const blob = await storage.get(await request.text())return new Response(blob, {headers: {'Content-Type': blob.type,'Content-Length': blob.size.toString(),'Content-Disposition': `attachment; filename=${blob.name}`}})}}