xmtplabs/xmtp-agent-examples / skills/handling-attachments
handling-attachments
VerifiedFile attachment handling for XMTP agents. Use when sending or receiving images, files, or any encrypted remote attachments. Triggers on file upload, image sending, or remote attachment handling.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 1.8 KB |
| rules/receive-attachment.md | markdown | 1.2 KB |
| rules/send-remote-attachment.md | markdown | 1.1 KB |
| rules/upload-callback.md | markdown | 1.6 KB |
rules/upload-callback.md
View on GitHub---
title: Implement custom upload storage
impact: HIGH
tags: attachments, upload, storage, pinata
---
## Implement custom upload storage
Create an upload callback to store encrypted files on your storage provider.
**Pinata example:**
```typescript
import { type AttachmentUploadCallback } from "@xmtp/agent-sdk";
import { PinataSDK } from "pinata";
const uploadCallback: AttachmentUploadCallback = async (attachment) => {
const pinata = new PinataSDK({
pinataJwt: process.env.PINATA_JWT,
pinataGateway: process.env.PINATA_GATEWAY,
});
// Create blob from encrypted payload
const mimeType = "application/octet-stream";
const encryptedBlob = new Blob(
[Buffer.from(attachment.content.payload)],
{ type: mimeType }
);
const encryptedFile = new File([encryptedBlob], attachment.filename, {
type: mimeType,
});
// Upload to Pinata
const upload = await pinata.upload.public.file(encryptedFile);
// Return the public URL
return pinata.gateways.public.convert(`${upload.cid}`);
};
```
**S3 example pattern:**
```typescript
const uploadCallback: AttachmentUploadCallback = async (attachment) => {
const s3 = new S3Client({ region: "us-east-1" });
const key = `attachments/${Date.now()}-${attachment.filename}`;
await s3.send(new PutObjectCommand({
Bucket: process.env.S3_BUCKET,
Key: key,
Body: Buffer.from(attachment.content.payload),
ContentType: "application/octet-stream",
}));
return `https://${process.env.S3_BUCKET}.s3.amazonaws.com/${key}`;
};
```
**Required environment variables (Pinata):**
```bash
PINATA_JWT=your_jwt_token
PINATA_GATEWAY=your_gateway_url
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |