@uploadx/core
Version:
Node.js resumable upload middleware
62 lines (61 loc) • 1.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.METAFILE_EXTNAME = exports.MetaStorage = void 0;
const file_1 = require("./file");
const utils_1 = require("../utils");
/**
* Stores upload metadata
*/
class MetaStorage {
constructor(config) {
this.prefix = '';
this.suffix = '';
this.prefix = config?.prefix || '';
this.suffix = config?.suffix || exports.METAFILE_EXTNAME;
this.prefix && file_1.FileName.INVALID_PREFIXES.push(this.prefix);
this.suffix && file_1.FileName.INVALID_SUFFIXES.push(this.suffix);
this.logger = config?.logger || utils_1.logger;
}
/**
* Saves upload metadata
*/
async save(id, file) {
return file;
}
/**
* Deletes an upload metadata
*/
async delete(id) {
return;
}
/**
* Retrieves upload metadata
*/
async get(id) {
return Promise.reject();
}
/**
* Mark upload active
*/
async touch(id, file) {
return file;
}
/**
* Retrieves a list of uploads whose names begin with the prefix
* @experimental
*/
async list(prefix = '') {
return { items: [] };
}
getMetaName(id) {
return this.prefix + id + this.suffix;
}
getIdFromMetaName(name) {
return name.slice(this.prefix.length, -this.suffix.length);
}
}
exports.MetaStorage = MetaStorage;
/**
* @deprecated Use MetaStorage.suffix instead
*/
exports.METAFILE_EXTNAME = '.META';