🦭 Walrus Integration Deep Dive
Challenge: Uploading Large Video Files
Problem: Walrus HTTP API has a 10MB upload limit. Video files are often 1GB+.
Solution: Use Walrus CLI directly via Node.js child process with retry logic.
// Walrus CLI Upload (walrus.service.ts)
async uploadFile(filePath: string, options) {
const cmd = `walrus store \\
--config ${this.configPath} \\
--epochs ${options.epochs || 52} \\
${options.permanent ? '--permanent' : ''} \\
"${filePath}"`;
const result = await execAsync(cmd, {
timeout: 600000, // 10 minute timeout
maxBuffer: 50 * 1024 * 1024
});
// Parse: "Blob ID: 1vwtsnn3dPnDqouEHcTfG5aV..."
const blobId = this.parseBlobId(result.stdout);
return {
blobId,
url: `${this.aggregatorUrl}/v1/${blobId}`,
permanent: options.permanent
};
}
Retrieval via HTTP Aggregator
// Generate streaming URL
const streamingUrl = `https://aggregator.walrus.atalma.io/v1/${blobId}`;
// Video.js HLS player consumes this directly
<video src={streamingUrl} controls />