From 0cc62cf8768eb0d66be11b4db41d67f43c935a69 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Tue, 26 Mar 2024 07:33:22 -0400 Subject: [PATCH] file path and database added --- .env | 1 + index.js | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.env b/.env index 4b80416..1a8d278 100644 --- a/.env +++ b/.env @@ -1,2 +1,3 @@ WRENCHJOB_PORT=3000 WRENCHJOB_POSTGRE_URL='postgresql://wrenchboard:wrenchboard@10.20.30.60:5432/wrenchboard' +COMMON_MEDIA_PATH='/opt/wrenchboard/TEST/COMMON/MEDIA/' \ No newline at end of file diff --git a/index.js b/index.js index 58f9831..6c13dd6 100644 --- a/index.js +++ b/index.js @@ -1,11 +1,11 @@ const express = require('express') const fs = require('fs') - +const db = require('./app/db') const app = express() const cors = require("cors"); -const videoFileMap={ +const videoFileMap2={ 'cdn':'videos/v1.mp4', 'generate-pass':'videos/v2.mp4', 'get-post':'videos/v3.mp4', @@ -20,6 +20,21 @@ const videoFileMap={ 'tt9':'/opt/wrenchboard/TEST/COMMON/MEDIA/How to Install RabbitMQ Locally with Docker-(1080p60).mp4', } +const videoFileMap={ + 'cdn':'videos/v1.mp4', + 'generate-pass':'videos/v2.mp4', + 'get-post':'videos/v3.mp4', + 'tt1':'What Is Single Sign-on (SSO)? How It Works-(1080p25).mp4', + 'tt2':'What is RabbitMQ?-(1080p30).mp4', + 'tt3':'What is CORS?-(1080p50).mp4', + 'tt4':'SAML vs OAuth vs OIDC (explained simply!)-(1080p25).mp4', + 'tt5':'Running RabbitMQ Locally with Docker-(1080p60).mp4', + 'tt6':'React Proxy | Easiest Fix to CORS Errors-(2160p24).mp4', + 'tt7':'RabbitMQ Tutorial - Publisher and Consumer program with example in nodeJS-(686p30).mp4', + 'tt8':'RabbitMQ - RPC with NodeJs (request-reply pattern)-(1080p60).mp4', + 'tt9':'How to Install RabbitMQ Locally with Docker-(1080p60).mp4', +} + console.log("Finding File"); var corsOptions = { @@ -32,6 +47,9 @@ app.use(cors(corsOptions)); app.get('/videos/:filename', (req, res)=>{ const fileName = req.params.filename; + + + const filePath = videoFileMap[fileName] if(!filePath){ console.log("Finding File Not Found ", filePath); @@ -40,7 +58,9 @@ app.get('/videos/:filename', (req, res)=>{ console.log("Finding File Found ", filePath); - const stat = fs.statSync(filePath); + const completeFile = process.env.COMMON_MEDIA_PATH + filePath; + + const stat = fs.statSync(completeFile); const fileSize = stat.size; const range = req.headers.range;