File objects. file-storage gives Remix apps one consistent API across local disk and memory backends.
Features
- Simple API - Intuitive key/value API (like Web Storage, but for
Files instead of strings) - Multiple Backends - Built-in filesystem and memory backends
- Streaming Support - Stream file content to and from storage
- Metadata Preservation - Preserves all
Filemetadata includingfile.name,file.type, andfile.lastModified
Installation
Usage
File System Storage
Memory Storage
Memory storage is useful for testing and development:Working with File Uploads
file-storage pairs well with form-data-parser for handling file uploads:
Serving Files from Storage
Use with response helpers to serve files with proper HTTP semantics:Streaming Large Files
File storage works efficiently with large files using streams:API Reference
createFsFileStorage(directory)
Creates a file storage instance that stores files on the filesystem.
Parameters:
directory: string- Path to the directory where files will be stored
FileStorage
createMemoryFileStorage()
Creates a file storage instance that stores files in memory.
Returns: FileStorage
FileStorage
Interface for file storage implementations.
File Metadata
All standardFile properties are preserved:
name: string- The filenamesize: number- File size in bytestype: string- MIME typelastModified: number- Last modified timestamp
External Storage Backends
For cloud storage, use external backends:file-storage-s3- Amazon S3 backend for file storage
Related Packages
form-data-parser- Parse multipart/form-data requests with file uploadslazy-file- The streamingFileimplementation used internallyresponse/file- Create file responses with proper HTTP semantics