@plattar/plattar-api
Version:
Module for interfacing with the Plattar API (https://www.plattar.com)
59 lines (48 loc) • 1.6 kB
JavaScript
const PlattarBase = require("../interfaces/plattar-base.js");
const Server = require("../../server/plattar-server.js");
class FileBase extends PlattarBase {
constructor(id, server) {
super(id, server || Server.default());
if (this.constructor === FileBase) {
throw new Error("FileBase is abstract and cannot be created");
}
}
static type() {
const FileAudio = require("./file-audio.js");
const FileVideo = require("./file-video.js");
const FileModel = require("./file-model.js");
const FileImage = require("./file-image.js");
return [FileAudio, FileVideo, FileModel, FileImage];
}
/**
* Returns the full remote path of the file
* Use this path to download the object into your machine
*/
get sourcePath() {
if (!this.attributes.path) {
return null;
}
return this.path + this.attributes.original_filename;
}
/**
* Returns the full remote path of the file backup as a Zip File
* Use this path to download the object object into your machine
*/
get backupPath() {
if (!this.attributes.path) {
return null;
}
return this.path + this.attributes.original_upload;
}
/**
* Returns the remote head path to be used with other attributes
* to get the final path
*/
get path() {
if (!this.attributes.path) {
return null;
}
return this._query.server.originLocation.cdn + this.attributes.path;
}
}
module.exports = FileBase;