- const videoFilePath = join(CONFIG.STORAGE.VIDEOS_DIR, videoPhysicalFile.filename)
- const videoFileHeight = await getVideoFileHeight(videoFilePath)
+ const videoFileData = {
+ extname: extname(videoPhysicalFile.filename),
+ resolution: videoFileResolution,
+ size: videoPhysicalFile.size
+ }
+ const videoFile = new VideoFileModel(videoFileData)
+ const videoDir = CONFIG.STORAGE.VIDEOS_DIR
+ const destination = join(videoDir, video.getVideoFilename(videoFile))
+
+ await renamePromise(videoPhysicalFile.path, destination)
+ // This is important in case if there is another attempt in the retry process
+ videoPhysicalFile.filename = video.getVideoFilename(videoFile)
+ videoPhysicalFile.path = destination
+
+ // Process thumbnail or create it from the video
+ const thumbnailField = req.files['thumbnailfile']
+ if (thumbnailField) {
+ const thumbnailPhysicalFile = thumbnailField[0]
+ await processImage(thumbnailPhysicalFile, join(CONFIG.STORAGE.THUMBNAILS_DIR, video.getThumbnailName()), THUMBNAILS_SIZE)
+ } else {
+ await video.createThumbnail(videoFile)
+ }