Buckets
ICBucket
ICPay Cloud guide
On-chain encrypted file storage
ICBucket
On-chain encrypted file storage
ICBucket
On-chain encrypted file storage
Overview
Get started with ICBucket in under 5 minutes with our step-by-step onboarding walkthrough.
Get your decentralized storage pipeline operational in under five minutes. In this tutorial, you will initialize the official client SDK, connect using your bucket credentials, and upload your first file to the Internet Computer.
my-app-assets) and Read/Write API keyChoose your preferred package manager:
npm install icpay-bucketCreate or update your .env.local file:
ICBUCKET_API_KEY=icp_live_sec_994a8e2b
ICBUCKET_ID=my-app-assets
NEXT_PUBLIC_ICBUCKET_CDN=https://cdn.icpay.appCreate a small test script upload.ts:
import { ICBucket } from "icpay-bucket"
import fs from "node:fs"
async function main() {
const bucket = new ICBucket({
bucketId: process.env.ICBUCKET_ID!,
apiKey: process.env.ICBUCKET_API_KEY!,
})
const buffer = fs.readFileSync("./avatar.png")
// Upload directly to decentralized storage
const result = await bucket.uploadFile("avatar.png", buffer, {
contentType: "image/png",
visibility: "public",
})
console.log("Upload successful!")
console.log("CDN URL:", result.publicUrl)
console.log("Raw Canister URL:", result.rawUrl)
}
main().catch(console.error)Run your script:
npx tsx upload.tsTest access by opening the printed CDN URL in your browser or curling it:
curl -I https://cdn.icpay.app/cloud/my-app-assets/avatar.pngYou should receive an HTTP/2 200 OK response with Content-Type: image/png and edge cache headers.