astrolabe-file-storage

Abstract file upload, download, and delete operations across .NET storage backends.

1|5|Updated Aug 6, 2023
One-click install
npx skills add https://github.com/astrolabe-apps/astrolabe-common --skill astrolabe-file-storage
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: astrolabe-file-storage
Source: https://github.com/astrolabe-apps/astrolabe-common/tree/main/skills/astrolabe-file-storage
Command: npx skills add https://github.com/astrolabe-apps/astrolabe-common --skill astrolabe-file-storage

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a backend-agnostic file storage abstraction for .NET applications.

Core Features & Use Cases

  • IFileStorage<T> interface abstracts UploadFile, DownloadFile, and DeleteFile for any file reference type.
  • ByteArrayFileStorage demonstrates in-memory or database-backed storage with EF Core integration.
  • Use Cases: store user documents, avatars, or media across databases, cloud storage, or filesystem backends.

Quick Start

Install the Astrolabe.FileStorage package, define a FileEntity, configure ByteArrayFileStorage.Create<FileEntity> with create/getBytes/options/deleteFile, and inject IFileStorage<FileEntity> into services or controllers. Then call UploadFile, DownloadFile, or DeleteFile with appropriate requests.

Frequently Asked Questions about astrolabe-file-storage

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I abstract file storage in ASP.NET Core to support multiple backends?

You can abstract file storage in ASP.NET Core by implementing a generic IFileStorage<T> interface to handle UploadFile, DownloadFile, and DeleteFile operations across database, cloud, or filesystem backends. This backend-agnostic pattern decouples your storage logic from specific infrastructure.

How do I store files in a database using EF Core?

To store files in a database using EF Core, configure the ByteArrayFileStorage pattern by defining a FileEntity and mapping its byte array property. Inject IFileStorage<FileEntity> into your services to handle in-memory or database-backed binary file persistence directly through EF Core.

Can I use IFileStorage to manage user document uploads and downloads?

Yes, IFileStorage is designed to manage user document uploads and downloads. You inject the generic interface into your controllers or services, then invoke UploadFile and DownloadFile with appropriate request objects to handle user documents, avatars, or media.

What is the best way to switch file storage backends in .NET applications?

The best way to switch file storage backends in .NET applications is using a backend-agnostic abstraction like IFileStorage<T>. By configuring ByteArrayFileStorage.Create with specific create, getBytes, options, and deleteFile delegates, you can seamlessly swap between filesystems and cloud storage.

Does backend-agnostic file storage work for enterprise media storage scenarios?

Backend-agnostic file storage works effectively for enterprise media storage scenarios by providing a unified interface across databases, cloud storage, and filesystems. It handles typical enterprise file operations like uploading, downloading, and deleting media without coupling to a specific vendor.

How do I configure ByteArrayFileStorage for file uploads in .NET?

To configure ByteArrayFileStorage for file uploads in .NET, install the package, define your FileEntity, and use ByteArrayFileStorage.Create to map your create, getBytes, options, and deleteFile logic. Inject the resulting IFileStorage instance to execute UploadFile requests.