pikku-backblaze

$npx mdskill add pikkujs/pikku/pikku-backblaze

Manage file storage operations for Backblaze B2 using dedicated content methods.

  • Handles uploading, downloading, and generating secure links for files.
  • Integrates directly with the Backblaze B2 cloud storage service.
  • Triggers when B2Content methods are used or when the user mentions Backblaze B2.
  • Provides methods to return streams, buffers, or signed URLs for consumption.

SKILL.md

.github/skills/pikku-backblazeView on GitHub ↗
---
name: pikku-backblaze
description: 'Use when setting up Backblaze B2 file storage in a Pikku app. Covers B2Content for file uploads, downloads, and signed URLs.
TRIGGER when: code uses B2Content, user asks about Backblaze B2, or @pikku/backblaze.
DO NOT TRIGGER when: user asks about S3 storage (use pikku-aws).'
---

# Pikku Backblaze (B2 Content Storage)

`@pikku/backblaze` provides Backblaze B2-backed file storage implementing the `ContentService` interface.

## Installation

```bash
yarn add @pikku/backblaze
```

## API Reference

### `B2Content`

```typescript
import { B2Content } from '@pikku/backblaze'

const content = new B2Content(
  config: B2ContentConfig,
  logger: Logger
)
```

**Methods:**
- `signContentKey(key: string, dateLessThan: Date): Promise<string>` — Sign a content key
- `signURL(url: string, dateLessThan: Date): Promise<string>` — Sign a URL
- `getUploadURL(fileKey: string, contentType: string): Promise<{ uploadUrl, assetKey, uploadMethod?, uploadHeaders? }>` — Get upload URL
- `writeFile(assetKey: string, stream: ReadableStream): Promise<boolean>` — Write file
- `copyFile(assetKey: string, fromAbsolutePath: string): Promise<boolean>` — Copy local file to B2
- `readFile(assetKey: string): Promise<ReadableStream>` — Read file as stream
- `readFileAsBuffer(assetKey: string): Promise<Buffer>` — Read file as buffer
- `deleteFile(fileName: string): Promise<boolean>` — Delete file

## Usage Patterns

```typescript
import { B2Content } from '@pikku/backblaze'

const createSingletonServices = pikkuServices(async (config) => {
  const logger = new PinoLogger()
  const content = new B2Content(
    {
      applicationKeyId: config.b2KeyId,
      applicationKey: config.b2AppKey,
      bucketId: config.b2BucketId,
      cdnUrl: config.b2CdnUrl,
    },
    logger
  )
  return { config, logger, content }
})
```

More from pikkujs/pikku

SkillDescription
pikku-addon'Use when creating or consuming reusable function packages (addons) in Pikku. Covers wireAddon, addon(), pikkuAddonServices, pikkuAddonWireServices, addon package structure, and cross-project function sharing.
pikku-ai-agent'Use when building AI agents, chatbots, or LLM-powered assistants with Pikku. Covers pikkuAIAgent, tool registration, memory, streaming, and agent invocation.
pikku-ai-vercel'Use when setting up AI agent execution with the Vercel AI SDK in a Pikku app. Covers VercelAIAgentRunner for streaming and non-streaming AI agent steps.
pikku-ai-voice'Use when adding voice input (speech-to-text) or voice output (text-to-speech) to AI agents in a Pikku app. Covers voiceInput/voiceOutput middleware hooks and STT/TTS service interfaces.
pikku-auth-js'Use when integrating Auth.js (NextAuth) with a Pikku app. Covers createAuthHandler, createAuthRoutes, and Auth.js configuration.
pikku-aws'Use when setting up AWS services (S3, SQS, Secrets Manager) in a Pikku app. Covers S3Content for file storage, SQSQueueService for queues, and AWSSecrets for secret management.
pikku-cli'Use when building CLI commands with Pikku. Covers wireCLI, pikkuCLICommand, subcommands, options, parameters, custom renderers, and nested command groups.
pikku-concepts'Foundational guide to Pikku framework concepts. Use this skill when working with any Pikku codebase, starting a new Pikku project, or migrating a backend to Pikku. Covers the core mental model, function types, project structure, code generation, testing, and how Pikku maps to traditional backend patterns.
pikku-config'Use when managing secrets, environment variables, config, or OAuth2 credentials in a Pikku app. Covers wireSecret, wireVariable, wireOAuth2Credential, and typed config access.
pikku-cron'Use when adding scheduled tasks, recurring jobs, or cron-based automation to a Pikku app. Covers wireScheduler, cron expressions, scheduled task wire object, and scheduler middleware.