Installation
The Media module runs inside a project that loads @antelopejs/dms, a database module and a module implementing @antelopejs/interface-file-storage (for example @antelopejs/file-storage-local).
Requirements
| Package | Version |
|---|---|
@antelopejs/dms | >=0.9.0 <1.0.0 |
@antelopejs/interface-dms | >=0.7.2 <1.0.0 |
@antelopejs/dms-frontend (the renderer) | 0.6 |
@antelopejs/interface-dms-media | >=0.3.0 <0.4.0 |
Add it to a project
Add the module
ajs project modules add @antelopejs/dms-media
Point the storage and the links at the public API URL
Files are uploaded straight to the storage, and copied links start with the module's publicBaseUrl. Point both at the api module's public base URL:
export default defineConfig({
name: "my-project",
modules: {
"dms-media": {
source: { type: "package", package: "@antelopejs/dms-media", version: "^0.5.0" },
config: {
publicBaseUrl: "${@api.API_PUBLIC_BASE_URL}",
},
},
"file-storage-local": {
source: { type: "package", package: "@antelopejs/file-storage-local", version: ">=0.1.6 <1.0.0" },
config: {
storagePath: ".antelope/file-storage",
baseUrl: "${@api.API_PUBLIC_BASE_URL}",
defaultVisibility: "private",
},
},
// dms, api, mongodb, auth-jwt, ...
},
});
Allow the dashboard's origin
The browser asks the API to presign an upload, then PUTs the file straight to the storage URL, which is another origin than the dashboard's. List every origin the dashboard is served on in the api module's CORS settings:
api: {
config: {
cors: {
allowedOrigins: ["https://dms.example.com"],
},
},
},
Open the library
Restart the backend and the frontend. The module appears under Modules › Media, at /modules/media/overview.
The pages render on the server: the overview, the library's folder tree and listing (a folder, view or search link included) and the file page arrive with their data. The image editor's canvas, the dialogs and the asset field's picker read in the browser.
PUT (the console shows a CORS error on /file-storage/...). The upload queue then names the origin to add; retrying does not help until it is allowed.Try it in the playground
pnpm install --frozen-lockfile
pnpm --dir packages/dms-media/frontend-vue install --frozen-lockfile
pnpm --dir packages/dms-media/playground install --frozen-lockfile --ignore-workspace
pnpm dev # backend on http://localhost:5010
pnpm --dir packages/dms-media frontend:dev # dashboard on http://localhost:3001
The playground uses MongoDB at mongodb://localhost:27017 (set MONGO_URL to change it). Its Media demo page (/media-demo) holds every flavour of the AssetType picker: a cover image with a linked folder, a gallery with a maximum, a PDF-only spec sheet, documents in their own linked folder, and a free attachment.