I am working in a node.js project in which I need to upload .mp4 files to amazon s3.
I have 2 questions:
QUES 1: I uploaded the mp4 file to a private bucket to say the bucket name is 'videoobucket'. To view the video in a browser, I created its signed URL.
My question is:
It is a ULR signed, which turns out to be different from the URL STREAMED. IF yes, what steps should I follow to create a streaming URL?
QUES 2: I need to create a thumbnail of the video that I am going to upload to amazon s3. How to do this in node.js?
I'm new to amazon and node.
Thank you all in advance!
The code I wrote to upload the files is as follows:
var file = req.files.video;
var fileName = new Date().getTime() + "_" + file.originalname;
fs.readFile(file.path, function(err, data) {
if (err) throw err;
var s3bucket = new AWS.S3({
params: {
Bucket: 'myvideos'
}
});
s3bucket.createBucket(function() {
var params = {
Key: fileName,
Body: data,
ContentType: file.type,
};
s3bucket.upload(params, function(err, data) {
fs.unlink(file.path, function(err) {
if (err) {
console.error(err);
}
});
if (err) {
res.status(500).send(err);
} else { console.log("file uploaded"); }
});
});
});