Install any skill in seconds. Free to start, no credit card required.
Get Started Free →General file/object storage, such as for images, videos, files, documents and other bulk data. Perfect fit for image galleries, video galleries, and other file or object management. Supports large files beyond IC limit, with browser-cached HTTP URL access.
.claude/skills/aiskillstore-extension-object-storage/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-19 | ✗→✓ | ▲ Improved | 127% | 0% |
| case-01 | ✗→✓ | ▲ Improved | -12% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 122% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 20% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 64% | 0% |
Object storage extension for Caffeine AI.
This skill adds off-chain file/object storage with on-chain references. The MixinObjectStorage mixin provides infrastructure for file operations; you track uploaded files in your own data structures using Storage.ExternalBlob.
All four steps are mandatory. Skipping any one causes 403 Forbidden: Invalid payload at upload time.
caffeineai-object-storage to mops.toml under [dependencies].include MixinObjectStorage() in main.mo (imported from "mo:caffeineai-object-storage/Mixin").Storage.ExternalBlob, never Text.@caffeineai/object-storage installed and ExternalBlob.fromBytes(bytes, file.type, file.name) used at the call site.CRITICAL: The frontend package (@caffeineai/object-storage) does NOT work without the backend mops package (caffeineai-object-storage). Installing only the npm package and not the mops package causes silent upload failures (403 from the storage gateway). You MUST install both together.
File content is stored off-chain. The backend manages references to external files using the Storage.ExternalBlob type from mo:caffeineai-object-storage/Storage. The frontend handles the actual upload/download; the backend only stores the reference.
CRITICAL: ANY data field that represents a file, image, photo, document, or media MUST use Storage.ExternalBlob as its type -- NEVER Text. Using Text breaks the upload/download proxy. Method parameters that accept file uploads MUST also use Storage.ExternalBlob, not Text.
Correct:
blob : Storage.ExternalBlobWrong:
blobId : Text
imageUrl : Text
fileRef : TextThe only type you use from mo:caffeineai-object-storage/Storage is ExternalBlob (which is Blob). All other functions in Storage.mo are internal infrastructure used by MixinObjectStorage -- do not call them directly.
include MixinObjectStorage() MUST be placed in main.mo, not in a custom mixin file. Your own file-tracking logic goes in a separate mixin.
motoko filepath=src/backend/main.moimport MixinObjectStorage "mo:caffeineai-object-storage/Mixin"; import Storage "mo:caffeineai-object-storage/Storage"; actor { include MixinObjectStorage(); // Track file references type Data = { id: Text; blob: Storage.ExternalBlob; name: Text; // other metadata }; };
NEVER create your own implementation of _immutableObjectStorageCreateCertificate or any other _immutableObjectStorage* method. These are platform-reserved method names provided exclusively by the MixinObjectStorage mixin from the mops package. Hand-written implementations produce wrong return types and cause 403 Forbidden: Invalid payload at upload time.
Wrong — inline stub in main.mo:
motoko filepath=wrong.mo// WRONG: Do not write this yourself public shared func _immutableObjectStorageCreateCertificate(fileHash : Text) : async Blob { CertifiedData.set(Blob.fromArray(hashBytes)); Blob.fromArray([]) };
Wrong — custom mixin file mimicking the platform shape:
motoko filepath=wrong-mixin.mo// WRONG: Do not create src/backend/mixins/object-storage-api.mo import ObjectStorageMixin "mixins/object-storage-api"; include ObjectStorageMixin();
The correct import path is ALWAYS "mo:caffeineai-object-storage/Mixin" — a mops package, never a relative path. Any relative import like "mixins/object-storage-api" or "./ObjectStorage" is wrong.
The correct signature produced by the platform mixin is:
_immutableObjectStorageCreateCertificate : (blobHash : Text) -> async record { method : Text; blob_hash : Text }Any other return type (Blob, (), Text, etc.) will fail gateway validation.
Backend Blob fields are represented as ExternalBlob on the frontend.
typescriptimport { ExternalBlob } from "@caffeineai/object-storage"; import type { FileRecord } from "@caffeineai/object-storage";
typescriptclass ExternalBlob { getBytes(): Promise<Uint8Array<ArrayBuffer>>; getDirectURL(): string; static fromURL(url: string): ExternalBlob; static fromBytes( blob: Uint8Array<ArrayBuffer>, contentType?: string, filename?: string, ): ExternalBlob; withUploadProgress(onProgress: (percentage: number) => void): ExternalBlob; }
Pass the browser File type and name into fromBytes so the gateway blob tree stores Content-Type and Content-Disposition (original filename). Also pass file.name to the backend so app records keep the filename for lists and UI.
typescriptconst handleUpload = async (file: File) => { const bytes = new Uint8Array(await file.arrayBuffer()); const blob = ExternalBlob.fromBytes(bytes, file.type, file.name).withUploadProgress((pct) => { setProgress(pct); }); await actor.uploadFile(file.name, blob); };
Gateway GET/HEAD responses echo the stored filename via Content-Disposition. Keep the backend filename field for queries and display without hitting the gateway.
Use getDirectURL() for inline display (images, videos). This returns an opaque proxy URL -- it has no file extension, so never inspect the URL to determine file type.
typescript<img src={record.blob.getDirectURL()} alt={record.filename} />
CRITICAL: Never detect file types by inspecting the URL from getDirectURL(). These are opaque proxy URLs with no extension. Instead use the filename field from the backend record:
typescriptconst isImage = (filename: string) => /\.(jpg|jpeg|png|gif|webp|svg|bmp|ico)$/i.test(filename); // Conditional rendering {isImage(record.filename) ? ( <img src={record.blob.getDirectURL()} alt={record.filename} /> ) : ( <div>{record.filename}</div> )}
If the backend also returns a mimeType field, prefer that:
typescriptconst isImage = (mimeType?: string) => mimeType?.startsWith("image/");
For downloads with the original filename, use getBytes() to create a downloadable link:
typescriptconst handleDownload = async (record: FileRecord) => { const bytes = await record.blob.getBytes(); const blob = new Blob([bytes]); const url = URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; a.download = record.filename; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); };
Use getDirectURL() for inline display, getBytes() for save-as downloads.
| Use case | Method | Notes | |---|---|---| | Display image/video | blob.getDirectURL() | Streaming, cached | | Download with filename | blob.getBytes() | Wrap in Blob + anchor | | Upload from browser | ExternalBlob.fromBytes(bytes, file.type, file.name) | MIME + filename in gateway headers | | Detect file type | filename or mimeType field | NEVER inspect the URL |
Confirm the backend has the mops dependency installed. Check src/backend/mops.toml:
toml[dependencies] caffeineai-object-storage = "0.1.2"
If caffeineai-object-storage is missing from [dependencies], object storage will not work regardless of what the frontend does. Add it, run mops install, and rebuild.
| Error | Cause | Fix | |---|---|---| | 403 Forbidden: Invalid payload on PUT /v1/blob-tree/ | Backend canister missing _immutableObjectStorageCreateCertificate or returning wrong type | Install caffeineai-object-storage in mops.toml, add include MixinObjectStorage() in main.mo, redeploy | | 403 Forbidden: Invalid payload (all files) | @caffeineai/object-storage npm installed but caffeineai-object-storage mops NOT installed | Add the mops dependency and rebuild backend | | Method exists but still 403 | Hand-written stub returns wrong type (e.g. Blob or () instead of record { method; blob_hash }) | Remove the custom implementation, use the platform mixin instead | | Forbidden: Owner does not have an account with the cashier | Cashier registration issue (unrelated to this skill) | Redeploy the backend canister to trigger self-healing registration |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-19 | fail→pass | 8,081 | 11,215 | +39% | 1 | 1 | 0% | 1,467 | 3,326 | +127% | 0 | 0 | — |
case-20 | pass→pass | 12,246 | 11,125 | -9% | 1 | 1 | 0% | 1,891 | 4,100 | +117% | 0 | 0 | — |
case-01 | fail→pass | 41,276 | 22,875 | -45% | 1 | 1 | 0% | 7,163 | 6,278 | -12% | 0 | 0 | — |
case-02 | fail→pass | 50,319 | 20,830 | -59% | 1 | 1 | 0% | 2,146 | 4,761 | +122% | 0 | 0 | — |
case-03 | fail→pass | 32,887 | 24,926 | -24% | 1 | 1 | 0% | 5,591 | 6,684 | +20% | 0 | 0 | — |
case-09 | fail→pass | 19,088 | 7,008 | -63% | 1 | 1 | 0% | 2,194 | 3,609 | +64% | 0 | 0 | — |
case-04 | fail→fail | 27,556 | 32,285 | +17% | 1 | 1 | 0% | 4,167 | 6,362 | +53% | 0 | 0 | — |
case-05 | pass→pass | 10,451 | 7,902 | -24% | 1 | 1 | 0% | 1,998 | 3,718 | +86% | 0 | 0 | — |
case-06 | pass→pass | 18,859 | 14,470 | -23% | 1 | 1 | 0% | 2,239 | 4,597 | +105% | 0 | 0 | — |
case-07 | fail→pass | 18,660 | 4,918 | -74% | 1 | 1 | 0% | 2,301 | 3,212 | +40% | 0 | 0 | — |
case-08 | fail→pass | 20,005 | 12,192 | -39% | 1 | 1 | 0% | 2,282 | 3,640 | +60% | 0 | 0 | — |
case-10 | fail→pass | 13,993 | 7,880 | -44% | 1 | 1 | 0% | 2,618 | 3,701 | +41% | 0 | 0 | — |
case-11 | fail→pass | 17,017 | 8,537 | -50% | 1 | 1 | 0% | 2,166 | 4,056 | +87% | 0 | 0 | — |
case-12 | fail→pass | 11,590 | 10,995 | -5% | 1 | 1 | 0% | 1,994 | 3,377 | +69% | 0 | 0 | — |
case-13 | fail→pass | 19,711 | 11,482 | -42% | 1 | 1 | 0% | 2,202 | 3,501 | +59% | 0 | 0 | — |
case-14 | fail→pass | 9,123 | 3,987 | -56% | 1 | 1 | 0% | 1,586 | 2,931 | +85% | 0 | 0 | — |
case-15 | fail→pass | 12,239 | 5,438 | -56% | 1 | 1 | 0% | 2,050 | 3,202 | +56% | 0 | 0 | — |
case-16 | fail→pass | 14,782 | 19,934 | +35% | 1 | 1 | 0% | 2,383 | 3,239 | +36% | 0 | 0 | — |
case-17 | pass→pass | 16,714 | 12,505 | -25% | 1 | 1 | 0% | 2,108 | 3,633 | +72% | 0 | 0 | — |
case-18 | fail→pass | 16,751 | 8,703 | -48% | 1 | 1 | 0% | 1,856 | 2,797 | +51% | 0 | 0 | — |
case-21 | fail→pass | 15,172 | 8,467 | -44% | 1 | 1 | 0% | 1,753 | 2,793 | +59% | 0 | 0 | — |
case-22 | fail→pass | 23,166 | 13,399 | -42% | 1 | 1 | 0% | 3,392 | 4,067 | +20% | 0 | 0 | — |
case-23 | fail→pass | 21,116 | 11,383 | -46% | 1 | 1 | 0% | 2,405 | 3,362 | +40% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted, and 22 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +78 percentage points is the difference between those two pass rates over the 22 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.