UNPKG

lincd

Version:

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

49 lines 1.67 kB
export 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); } } /** * Get the full path of an asset based on the way LinkedFileStorage is configured * Returns accessURL + directory (/public by default) + path * @param path asset path * @param directory asset directory (optional, default is /public) * @returns asset url. e.g. https://cdn.example.com/public/image.png */ export function asset(path, directory = '/public') { const accessURL = LinkedFileStorage.accessURL; const assetUrl = accessURL + directory + path; return assetUrl; } //# sourceMappingURL=LinkedFileStorage.js.map