UNPKG

lincd

Version:

LINCD is a JavaScript library for building user interfaces with linked data (also known as 'structured data', or RDF)

54 lines 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LinkedFileStorage = void 0; exports.asset = asset; class LinkedFileStorage { static get accessURL() { // check if default store is not set, return default accessURL if (!this.defaultStore) { return this.url; } return this.defaultStore.accessURL; } static setDefaultAccessURL(accessURL) { return (this.url = accessURL); } static getDefaultStore() { return this.defaultStore; } static setDefaultStore(store) { this.defaultStore = store; if (this.defaultStore.init) { this.defaultStore.init(); } } static deleteFile(filePath) { return this.defaultStore.deleteFile(filePath); } static fileExists(filePath) { return this.defaultStore.fileExists(filePath); } static getFile(filePath) { return this.defaultStore.getFile(filePath); } static listFiles(prefix) { return this.defaultStore.listFiles(prefix); } static saveFile(filePath, fileContent, mimeType, preventDuplicates = false) { return this.defaultStore.saveFile(filePath, fileContent, mimeType, preventDuplicates); } } exports.LinkedFileStorage = LinkedFileStorage; /** * Get the full path of an asset based on the way LinkedFileStorage is configured * * @param path asset path * @param directory asset directory (optional, default is /public) * @returns asset url. e.g. https://cdn.example.com/public/image.png */ function asset(path, directory = '/public') { const accessURL = LinkedFileStorage.accessURL; const assetUrl = accessURL + directory + path; return assetUrl; } //# sourceMappingURL=LinkedFileStorage.js.map