An in-memory StorageProvider: blobs in a Map, plus three inspection
methods. Published, unlike the copilot’s scripted model.
id:memory- Capabilities:
{ directUrl: false, contentTypeMetadata: true, streamingPut: false }
Not for a deployment
Blobs die with the process. On the next boot, the storage check refuses the database, because its rows point at bytes that are gone.
Install and register
npm install --save-dev @orthacms/media-provider-memoryimport { createMemoryStorageProvider } from '@orthacms/media-provider-memory';
export const storage = createMemoryStorageProvider({
maxTotalBytes: 64 * 1024 * 1024 // default 256 MB
});
MediaServerPlugin({
provider: storage,
config: { directServe: 'off', maxUploadBytes: 10 * 1024 * 1024 }
});No environment variables. MemoryStorageConfig is { maxTotalBytes? }.
Inspect it in a test
| Method | Returns |
|---|---|
keys() | Every stored key, sorted |
totalBytes() | Current size |
clear() | Empties the store |
afterEach(() => storage.clear());
it('stores the original and its derivatives', async () => {
const asset = await uploadFixture('kingfisher.jpg');
expect(storage.keys()).toEqual([
`${workspaceId}/${asset.id}/kingfisher.jpg`,
`${workspaceId}/${asset.id}/variants/preview.webp`,
`${workspaceId}/${asset.id}/variants/thumb.webp`
]);
});
it('removes the blobs when the asset is deleted', async () => {
const asset = await uploadFixture('kingfisher.jpg');
await deleteAssets([asset.id]);
expect(storage.totalBytes()).toBe(0);
});uploadFixture and deleteAssets stand for your own helpers around
POST /api/media/assets and DELETE /api/media/assets.
Behaviour worth knowing
MemoryStoreFullErrorwhen aputwould exceedmaxTotalBytes, so a runaway test fails as a test, not an out-of-memory kill.putbuffers (streamingPut: false): nothing reaches theMapuntil the body has fully arrived, so a failed body leaves the store unchanged.- Keys match the local provider’s layout, so assertions can be shared.
- It passes the same contract suite as every other backend.