Objektspeicherintegration
Kapselt Speicheranbieterunterschiede in einem praktischen Adapter mit erhaltenen Streaming-, Signierungs- und Browserupload-Anforderungen.
object-storage-integration
Teammitglieder mit diesem Skill
Wann ist der Skill hilfreich?
Nutze ihn beim Einbinden von Cloud- oder lokalem Objektspeicher ohne verteilte SDK-Details in der Anwendungslogik.
Wobei hilft er dir?
- Definiert Adapteroperationen für Streams, Metadaten, Signierung und Kopieren.
- Prüft Anbieterbesonderheiten statt S3-Gleichheit anzunehmen.
- Konfiguriert genaue Browserursprünge und sichtbare Multipart-ETag-Header.
Das könntest du fragen
Integriere private R2-Uploads mit Prüfsummen und mehrteiligem Browserabschluss. Lade Browserteile hoch, vervollständige das Objekt und prüfe die Prüfsumme. Teste verbotenen Ursprung und abgelaufene Signatur, ohne das Objekt öffentlich zu machen.
Ausführliche Dokumentation
Hier findest du die ursprüngliche Anleitung, Beispiele und Prüfschritte des Skills in ihrer Originalsprache.
Weniger anzeigen
Object Storage Integration
While AWS S3, Cloudflare R2, MinIO, Backblaze B2, DigitalOcean Spaces, Google Cloud Storage, Azure Blob Storage and local disk all store byte blobs by key, their consistency guarantees, presigned URL capabilities, CORS rules, checksum headers and metadata limits differ. Hide vendor mechanics behind a narrow storage port while respecting provider-specific constraints.
1. Designing the Storage Adapter Boundary
Define a clean internal interface for storage operations without leaking SDK types into business services:
putStream(key, readableStream, { contentType, contentLength, sha256, metadata })getStream(key, { range }) -> { stream, contentLength, contentType, etag }head(key) -> { exists, sizeBytes, contentType, etag, checksum, lastModified }createPresignedUpload(key, { contentType, contentLengthRange, expiresInSeconds, checksumSha256 })createPresignedDownload(key, { expiresInSeconds, responseContentDisposition, responseContentType })delete(key)(idempotent — succeeds when object is already absent)copy(sourceKey, destKey)
2. Provider-Specific Capabilities & Gotchas
- AWS S3:
- Block Public Access (
BlockPublicAcls,IgnorePublicAcls,BlockPublicPolicy,RestrictPublicBuckets) must be enabled on private buckets. - Supports both presigned
PUT(exact headers bound into signature) and presignedPOST(supports["content-length-range", min, max]policy conditions!).
- Block Public Access (
- Cloudflare R2 / MinIO / S3-Compatible Stores:
- Verify whether
createPresignedPostis supported by the target provider (some S3-compatible providers only support presignedPUT+Content-Lengthbinding). - Set
region: 'auto'(for R2) orforcePathStyle: true(for local MinIO / custom endpoints) in@aws-sdk/client-s3.
- Verify whether
- Azure Blob Storage:
- Uses Block Blobs (
StageBlock->CommitBlockListfor chunked uploads) and SAS (Shared Access Signature) tokens (BlobSASPermissions:r,w,c,dscoped to exact blob path, start/expiry time andhttpsprotocol).
- Uses Block Blobs (
- Local Filesystem (Development / Self-Hosted Single-Node):
- Write uploads to a temporary file on the same filesystem mount as the target directory, then
fs.rename()atomically into place once the stream and checksum succeed so readers never observe a half-written file. - Shard directories by prefix (
blobs/ab/cd/abcdef...) so a single folder never accumulates millions of inodes.
- Write uploads to a temporary file on the same filesystem mount as the target directory, then
3. Browser CORS & Checksum Headers
Direct browser-to-object-store uploads fail silently if bucket CORS is misconfigured:
- Allow only the application's exact origins (
AllowedOrigins), methods (PUT,POST,GET,HEAD), and required headers (Content-Type,Content-MD5,x-amz-checksum-sha256,x-ms-blob-type). - Expose
ETaginExposeHeaders(Access-Control-Allow-Headers/Access-Control-Expose-Headers: ETag) — without it, browser JavaScript cannot read theETagresponse header required to complete S3 Multipart uploads!
Enthaltene Dateien 1
SKILL.md
