pixeldrainjs
Version:
A NodeJS Wrapper for the pixeldrain.com API
43 lines • 1.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PixelDrain = void 0;
const file_1 = require("./components/file/file");
const pixeldrainservice_1 = require("./services/pixeldrainservice");
class PixelDrain {
constructor(APIKey = "") {
this.pixeldrainService = new pixeldrainservice_1.PixeldrainService(APIKey);
}
/**
* Retrieves file information from the API and returns it as a PixeldrainFile Object
*
* @param {string} id File ID
* @return {*} {Promise<PixeldrainFile>}
* @memberof PixelDrain
*/
getFile(id) {
return new Promise((resolve, reject) => {
this.pixeldrainService.getFileInfo(id)
.then((data) => {
resolve(new file_1.PixeldrainFile(data, this.pixeldrainService));
})
.catch(reject);
});
}
/**
* Uploads a file to pixeldrain. A File can either be uploaded anonymously or under a user account
*
* @param {PixeldrainFileUploadOptions} file File Information
* @return {*} {Promise<PixeldrainFile>}
* @memberof PixelDrain
*/
uploadFile(file) {
return new Promise((resolve, reject) => {
this.pixeldrainService.uploadFile(file)
.then((id) => this.pixeldrainService.getFileInfo(id))
.then((fileInfo) => resolve(new file_1.PixeldrainFile(fileInfo, this.pixeldrainService)))
.catch(reject);
});
}
}
exports.PixelDrain = PixelDrain;
//# sourceMappingURL=index.js.map