UNPKG

@webda/core

Version:

Expose API with Lambda

58 lines 1.47 kB
import { join } from "path"; import { BinaryParameters, BinaryService } from "./binary.js"; /** * Default binary parameters */ export class CloudBinaryParameters extends BinaryParameters { constructor(params, service) { super(params, service); this.prefix ?? (this.prefix = ""); } } /** * CloudBinary abstraction */ export class CloudBinary extends BinaryService { /** * @override */ loadParameters(params) { return new CloudBinaryParameters(params, this); } /** * Get a UrlFromObject * */ async getRedirectUrlFromObject(binaryMap, context, expires = 30) { return this.getSignedUrlFromMap(binaryMap, expires, context); } /** * Return the S3 key * @param hash * @param suffix * @returns */ _getKey(hash, suffix = "data") { return join(`${this.parameters.prefix}`, hash, suffix); } /** * @inheritdoc */ async delete(object, property, index) { let hash = object[property][index].hash; await this.deleteSuccess(object, property, index); await this._cleanUsage(hash, object.getUuid(), property); } /** * @inheritdoc */ async cascadeDelete(info, uuid) { try { await this._cleanUsage(info.hash, uuid); } catch (err) { this._webda.log("WARN", "Cascade delete failed", err); } } } //# sourceMappingURL=cloudbinary.js.map