82 lines
2.4 KiB
JavaScript
82 lines
2.4 KiB
JavaScript
|
"use strict";
|
||
|
(() => {
|
||
|
var exports = {};
|
||
|
exports.id = 1460;
|
||
|
exports.ids = [1460];
|
||
|
exports.modules = {
|
||
|
|
||
|
/***/ 7147:
|
||
|
/***/ ((module) => {
|
||
|
|
||
|
module.exports = require("fs");
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ 1017:
|
||
|
/***/ ((module) => {
|
||
|
|
||
|
module.exports = require("path");
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ 184:
|
||
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||
|
|
||
|
__webpack_require__.r(__webpack_exports__);
|
||
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||
|
/* harmony export */ "config": () => (/* binding */ config),
|
||
|
/* harmony export */ "default": () => (/* binding */ handler)
|
||
|
/* harmony export */ });
|
||
|
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7147);
|
||
|
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
|
||
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1017);
|
||
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
|
||
|
// @ts-check
|
||
|
|
||
|
|
||
|
const config = {
|
||
|
api: {
|
||
|
responseLimit: "1mb",
|
||
|
bodyParser: {
|
||
|
sizeLimit: "200mb"
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
/**
|
||
|
* @type {import("next").NextApiHandler}
|
||
|
*/ async function handler(req, res) {
|
||
|
/**
|
||
|
* Check method
|
||
|
*
|
||
|
* @description Check request method and return if invalid
|
||
|
*/ if (req.method !== "GET") return res.json({
|
||
|
msg: "Failed!"
|
||
|
});
|
||
|
const mediaUrl = req.query.url;
|
||
|
const mediaPath = String(mediaUrl).replace(process.env.DSQL_STATIC_HOST || "", "");
|
||
|
const mediaStoragePath = path__WEBPACK_IMPORTED_MODULE_1___default().join(process.env.DSQL_STATIC_SERVER_DIR || "", "/", mediaPath);
|
||
|
if (fs__WEBPACK_IMPORTED_MODULE_0___default().existsSync(mediaStoragePath)) {
|
||
|
console.log("mediaStoragePath", mediaStoragePath);
|
||
|
const readStream = fs__WEBPACK_IMPORTED_MODULE_0___default().createReadStream(mediaStoragePath);
|
||
|
readStream.pipe(res);
|
||
|
} else {
|
||
|
return res.json({
|
||
|
success: false
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
/***/ })
|
||
|
|
||
|
};
|
||
|
;
|
||
|
|
||
|
// load runtime
|
||
|
var __webpack_require__ = require("../../webpack-api-runtime.js");
|
||
|
__webpack_require__.C(exports);
|
||
|
var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
|
||
|
var __webpack_exports__ = (__webpack_exec__(184));
|
||
|
module.exports = __webpack_exports__;
|
||
|
|
||
|
})();
|