Inspected version: 0.1.3 · Source →
File storage facade with a built-in local filesystem provider and a custom provider contract.
Entry points#
The manifest exports ., /providers/local, /types and /package.json.
Main exports#
StorageServiceStorageServiceProviderLocalFileProviderIStorageService,IStorageProviderStorageData,StorageError,StorageResultSTORAGE_SERVICE
StorageService#
registerProvider(provider)unregisterProvider(id)setDefaultProvider(id)getDefaultProviderId()upload(file, providerId?)delete(keyOrUrl, providerId?)getProviders()
The service chooses an explicitly requested provider or the default; if that provider is not registered, it falls back to "local". A provider must still be registered for the operation to succeed. delete() returns false if deletion is unsupported or no provider is available.
Result contract#
A successful StorageResult has name, url, type, size, service, and serviceId. A failure is { error: string }. Always narrow the union before reading success-only fields.
Local provider#
LocalFileProvider reads FILE_STORAGE_FOLDER from ConfigService or process.env; the fallback is public/uploads. It rejects files without an extension and a list of dangerous extensions, writes a generated filename, and returns a URL plus provider-local serviceId.
These checks are defense-in-depth, not a complete upload security policy. Validate file size, content, authorization, visibility and storage persistence in the application. Local filesystem storage may not be persistent or writable on serverless hosts.