83 lines
2.9 KiB
JavaScript
83 lines
2.9 KiB
JavaScript
"use strict";
|
|
(() => {
|
|
var exports = {};
|
|
exports.id = 3620;
|
|
exports.ids = [3620];
|
|
exports.modules = {
|
|
|
|
/***/ 7147:
|
|
/***/ ((module) => {
|
|
|
|
module.exports = require("fs");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 1017:
|
|
/***/ ((module) => {
|
|
|
|
module.exports = require("path");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 2288:
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": () => (/* binding */ handler)
|
|
/* harmony export */ });
|
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1017);
|
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
|
|
// @ts-check
|
|
const fs = __webpack_require__(7147);
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
* API handler
|
|
* ==============================================================================
|
|
* @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: "Invalid Request"
|
|
});
|
|
const videoDir = path__WEBPACK_IMPORTED_MODULE_0___default().resolve(process.cwd(), "./public/videos");
|
|
const videoName = req.query.name;
|
|
if (!videoName || typeof videoName !== "string") {
|
|
res.status(400).end("No video name provided");
|
|
return;
|
|
}
|
|
const videoPath = path__WEBPACK_IMPORTED_MODULE_0___default().join(videoDir, videoName);
|
|
if (!fs.existsSync(videoPath)) {
|
|
res.status(400).end("Video not found");
|
|
return;
|
|
}
|
|
const stat = fs.statSync(videoPath);
|
|
const fileSize = stat.size;
|
|
const range = req.headers.range;
|
|
const videoReadStream = fs.createReadStream(videoPath);
|
|
videoReadStream.pipe(res);
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
}
|
|
|
|
|
|
/***/ })
|
|
|
|
};
|
|
;
|
|
|
|
// 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__(2288));
|
|
module.exports = __webpack_exports__;
|
|
|
|
})(); |