Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
A bug when stream video nodejs-aws

I have a video file on aws s3 and try to stream it to client through a nodejs-express server. this is my backend code

const S3 = require('aws-sdk/clients/s3');

const accessKeyId =  process.env.AWS_ACCESS_KEY
const secretAccessKey =   process.env.AWS_SECRET_KEY
const region = process.env.AWS_BUCKET_REGION
const bucketName = process.env.AWS_BUCKET_NAME

const s3 = new S3({
    region,
    accessKeyId,
    secretAccessKey,
})

function getFileStream(fileKey) {
    const downloadParams = {
        Key: fileKey,
        Bucket: bucketName
    }
    return s3.getObject(downloadParams).createReadStream();
}

async function getFileSize(fileKey) {
    const fileParams = {
        Key: fileKey,
        Bucket: bucketName
    }

    const data = await s3.headObject(fileParams).promise();
    return data.ContentLength;
}

router.get("/test-video-stream", async (req, res) => {
    const fileName = 'test-video';

    const fileSize = await getFileSize(fileName);
    const headers = {
        "Content-Range": `bytes 0-${fileSize}`,
        "Accept-Ranges": "bytes",
        "Content-Type": "video/mp4",
    };

    res.writeHead(200, headers)
    const fileStream = getFileStream(fileName);

    fileStream.pipe(res);
})

and this is my front end code

<video width="320" height="240" controls="">
   <source type="video/mp4" src="http://localhost:8000/test-video-stream">
</video>

I can play the video from start time 0:00 but can not click into time control bar of the video player to choose time for video start playing. Can anyone explain me why this happen ? Thank you a lot !

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!