Commit d602e394 by Pragati Upadhyay

conTentType

parent 792d8a31
......@@ -129,8 +129,8 @@ module.exports.generateVideo = async function (req, res) {
let remotePath = path.join(CONFIG.S3_TUTOR_SHOT, fileName)
let remoteThumbnailPath = path.join(CONFIG.S3_TUTOR_SHOT, thumbnailName)
let url = await uploadToAwsS3(videoPath, remotePath,{contentType:'video/mp4'})
await uploadThumbnailToAwsS3(thumbnailPath, remoteThumbnailPath)
let url = await uploadToAwsS3(videoPath, remotePath)
await uploadToAwsS3(thumbnailPath, remoteThumbnailPath)
tutorShotData.thumbnailUrl = remoteThumbnailPath
tutorShotData.signedVideoUrl = await generatePreSignedGetUrl(remotePath)
tutorShotData.signedThumbnailUrl = await generatePreSignedGetUrl(remoteThumbnailPath)
......
......@@ -13,7 +13,7 @@ const s3 = new AWS.S3({
region: CONFIG.S3_REGION,
})
module.exports.uploadToAwsS3 = async function (localPath, remotePath,contentType,options) {
module.exports.uploadToAwsS3 = async function (localPath, remotePath,options) {
const buffer = Fs.readFileSync(localPath);
......@@ -24,9 +24,6 @@ module.exports.uploadToAwsS3 = async function (localPath, remotePath,contentType
Bucket: CONFIG.S3_BUCKET_NAME,
Key: remotePath,
};
if(contentType?.contentType){
params.ContentType = contentType.contentType
}
s3.putObject(params, function (err, data) {
if (err) {
console.log(err);
......@@ -44,34 +41,7 @@ module.exports.uploadToAwsS3 = async function (localPath, remotePath,contentType
return { status: httpStatus.NETWORK_ERROR, path: remotePath }
}
}
module.exports.uploadThumbnailToAwsS3 = async function (localPath, remotePath,options) {
const buffer = Fs.readFileSync(localPath);
try {
var params = {
Body: buffer,
Bucket: CONFIG.S3_BUCKET_NAME,
Key: remotePath,
};
s3.putObject(params, function (err, data) {
if (err) {
console.log(err);
}
// successful response
});
if (options && !options.preventUnlink) {
try { Fs.unlinkSync(localPath) }
catch (err) { console.log(err) }
}
return
} catch (error) {
console.log(error);
return { status: httpStatus.NETWORK_ERROR, path: remotePath }
}
}
module.exports.generatePreSignedGetUrl = async function (fileName) {
return await new Promise((resolve, reject) => {
s3.getSignedUrl('getObject', {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment