Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
begenieus-jobs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ramdayal Munda
begenieus-jobs
Commits
792d8a31
Commit
792d8a31
authored
Jul 26, 2024
by
Pragati Upadhyay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conTentType
parent
0ef072ee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
3 deletions
+30
-3
tutor-shot.js
controller/tutor-shot.js
+2
-2
upload.js
helper/upload.js
+28
-1
No files found.
controller/tutor-shot.js
View file @
792d8a31
...
...
@@ -5,7 +5,7 @@ const sharp = require('sharp')
const
fs
=
require
(
'fs'
)
const
{
createVideoFromImages
,
createVideo
,
joinAudioVideo
}
=
require
(
"../helper/ffmpeg-helper"
)
const
{
deleteFile
,
downloadFile
}
=
require
(
"../helper/utilities"
)
const
{
generatePreSignedGetUrl
,
uploadToAwsS3
}
=
require
(
"../helper/upload"
)
const
{
generatePreSignedGetUrl
,
uploadThumbnailToAwsS3
,
uploadToAwsS3
}
=
require
(
"../helper/upload"
)
const
mongoose
=
require
(
'mongoose'
)
const
ObjectId
=
mongoose
.
Types
.
ObjectId
const
ffmpeg
=
require
(
"fluent-ffmpeg"
);
...
...
@@ -130,7 +130,7 @@ module.exports.generateVideo = async function (req, res) {
let
remoteThumbnailPath
=
path
.
join
(
CONFIG
.
S3_TUTOR_SHOT
,
thumbnailName
)
let
url
=
await
uploadToAwsS3
(
videoPath
,
remotePath
,{
contentType
:
'video/mp4'
})
await
uploadToAwsS3
(
thumbnailPath
,
remoteThumbnailPath
)
await
uploadT
humbnailT
oAwsS3
(
thumbnailPath
,
remoteThumbnailPath
)
tutorShotData
.
thumbnailUrl
=
remoteThumbnailPath
tutorShotData
.
signedVideoUrl
=
await
generatePreSignedGetUrl
(
remotePath
)
tutorShotData
.
signedThumbnailUrl
=
await
generatePreSignedGetUrl
(
remoteThumbnailPath
)
...
...
helper/upload.js
View file @
792d8a31
...
...
@@ -24,7 +24,7 @@ module.exports.uploadToAwsS3 = async function (localPath, remotePath,contentType
Bucket
:
CONFIG
.
S3_BUCKET_NAME
,
Key
:
remotePath
,
};
if
(
contentType
.
contentType
){
if
(
contentType
?
.
contentType
){
params
.
ContentType
=
contentType
.
contentType
}
s3
.
putObject
(
params
,
function
(
err
,
data
)
{
...
...
@@ -44,7 +44,34 @@ 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'
,
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment