UNPKG

1.43 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.LocalUFS = void 0;
4var fs = require("fs");
5var app_1 = require("./app");
6var LocalUFS = /** @class */ (function () {
7 function LocalUFS() {
8 }
9 LocalUFS.prototype.unlink = function (path, cb) {
10 fs.unlink(path, cb);
11 };
12 LocalUFS.prototype.stat = function (path) {
13 return new Promise(function (res, rej) {
14 fs.stat(app_1.app.config.uploadPath + "/" + path, function (err, r) {
15 if (err) {
16 return rej(err);
17 }
18 res(r);
19 });
20 });
21 };
22 LocalUFS.prototype.getToCache = function (path, _) {
23 return new Promise(function (res, _) {
24 return res(app_1.app.config.uploadPath + "/" + path);
25 });
26 };
27 LocalUFS.prototype.uploadFile = function (uploadMedia) {
28 return new Promise(function (res, _) {
29 return res(uploadMedia);
30 });
31 };
32 LocalUFS.prototype.uploadFileFromCache = function (path, cachePath) {
33 return new Promise(function (res, rej) {
34 fs.copyFile(cachePath + "/" + path, app_1.app.config.uploadPath + "/" + path, function (err) {
35 if (err) {
36 return rej(err);
37 }
38 return res();
39 });
40 });
41 };
42 return LocalUFS;
43}());
44exports.LocalUFS = LocalUFS;