Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Course ankit #77

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
improve the upload video api
AVtheking committed Nov 21, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 258620e95faff37e47d8e6b6e59c03ef32290fda
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:20-alpine

WORKDIR /usr/src/app

COPY package*.json ./


RUN npm install

COPY . .

EXPOSE 3000

CMD ["npm", "start"]
2 changes: 1 addition & 1 deletion controllers/course_controller.js
Original file line number Diff line number Diff line change
@@ -101,7 +101,7 @@ const courseCtrl = {
select: "_id username name profileimg domain bio",
})
.populate({
path: "videos",
path: "videos.video",
select:
"_id videoTitle videoUrl videoDuration videoUrl_144p videoUrl_360p videoUrl_720p",
});
22 changes: 16 additions & 6 deletions controllers/teacher_controller.js
Original file line number Diff line number Diff line change
@@ -163,7 +163,10 @@ const teacherCtrl = {
},

uploadVideo_toCourse: async (req, res, next) => {
let noteFilePath, videoFilePath, inputFilePath, inputFileName;
let noteFilePath = null,
videoFilePath,
inputFilePath,
inputFileName;
try {
const courseid = req.params.courseId;
// console.log(courseid);
@@ -194,11 +197,15 @@ const teacherCtrl = {

const notesfile = req.files.notes;
const videofile = req.files.video;

noteFilePath = "public/course_notes" + "/" + notesfile[0].filename;
if (!videofile) {
return next(new ErrorHandler(400, "Please upload a video file"));
}
if (notesfile) {
noteFilePath = "public/course_notes" + "/" + notesfile[0].filename;
}
videoFilePath = "public/course_videos" + "/" + videofile[0].filename;

course.notes.push(noteFilePath);
// course.notes.push(noteFilePath);

//Video Conversion using worker threads
const conversionPromise = resolutions.map((resolution) => {
@@ -234,7 +241,10 @@ const teacherCtrl = {
videoDuration: du,
});
video = await video.save();
course.videos.push(video._id);
course.videos.push({
video: video._id,
note: noteFilePath,
});

course = await course.save();

@@ -283,7 +293,7 @@ const teacherCtrl = {
course.isPublished = true;
course.price = price;
course.duration = duration;
course.preview=courses.videos[0];
course.preview = course.videos[0].video;
await course.save();

let existingCategory = await Category.findOne({ name: category });
25 changes: 14 additions & 11 deletions models/course.js
Original file line number Diff line number Diff line change
@@ -22,15 +22,16 @@ const courseSchema = new mongoose.Schema(

videos: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "Video",
},
],
notes: [
{
type: String,
video: {
type: mongoose.Schema.Types.ObjectId,
ref: "Video",
},
note: {
type: String,
},
},
],


category: {
type: String,
@@ -62,10 +63,12 @@ const courseSchema = new mongoose.Schema(
type: Number,
default: 0,
},
preview: [{
type: mongoose.Schema.Types.ObjectId,
ref: "Video",
}],
preview: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "Video",
},
],
isPublished: {
type: Boolean,
default: false,
Binary file added public/course_notes/notes-1700568312575.pdf
Binary file not shown.
Binary file added public/course_notes/notes-1700573169339.pdf
Binary file not shown.
Binary file added public/course_videos/video-1700568279122.mp4
Binary file not shown.
Binary file added public/course_videos/video-1700568281932.mp4
Binary file not shown.
Binary file added public/course_videos/video-1700568312527-144p.mp4
Binary file not shown.
Binary file added public/course_videos/video-1700568312527-360p.mp4
Binary file not shown.
Binary file added public/course_videos/video-1700568312527-720p.mp4
Binary file not shown.
Binary file added public/course_videos/video-1700568312527.mp4
Binary file not shown.
Binary file added public/course_videos/video-1700572809980-144p.mp4
Binary file not shown.
Binary file added public/course_videos/video-1700572809980-360p.mp4
Binary file not shown.
Binary file added public/course_videos/video-1700572809980-720p.mp4
Binary file not shown.
Binary file added public/course_videos/video-1700573169298-144p.mp4
Binary file not shown.
Binary file added public/course_videos/video-1700573169298-360p.mp4
Binary file not shown.
Binary file added public/course_videos/video-1700573169298-720p.mp4
Binary file not shown.
Binary file added public/course_videos/video-1700573169298.mp4
Binary file not shown.
Binary file added public/course_videos/video-1700573542399-144p.mp4
Binary file not shown.
Binary file added public/course_videos/video-1700573542399-360p.mp4
Binary file not shown.
Binary file added public/course_videos/video-1700573542399-720p.mp4
Binary file not shown.
Binary file added public/course_videos/video-1700573542399.mp4
Binary file not shown.