Quick Start
Get started with ICBucket in under 5 minutes with our step-by-step onboarding walkthrough.
Quick Start
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.
Prerequisites#
- Node.js 18+ or Python 3.9+
- An ICBucket created from the ICPay Dashboard
- Your Bucket ID (e.g.
my-app-assets) and Read/Write API key
Steps#
1. Install the SDK#
Choose your preferred package manager:
npm install icpay-bucket2. Configure Environment Variables#
Create or update your .env.local file:
ICBUCKET_API_KEY=icp_live_sec_994a8e2b
ICBUCKET_ID=my-app-assets
NEXT_PUBLIC_ICBUCKET_CDN=https://cloud.icpay.app3. Initialize the Client and Upload a File#
Create 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)Verification#
Run your script:
npx tsx upload.tsTest access by opening the printed CDN URL in your browser or curling it:
curl -I https://cloud.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.
Related Pages#
Edit this page on GitLabUpdated recently
Search documentation
Quickly find guides, APIs, and reference docs