]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/remote.js
Server: fix thumbnail in remote videos
[github/Chocobozzz/PeerTube.git] / server / controllers / api / remote.js
index 4085deb2d7e46309fc0257e5d1f35271c1e3d6c5..3e2aa6375f85df19c10e9d0bc358886e83897633 100644 (file)
@@ -55,11 +55,15 @@ function remoteVideos (req, res, next) {
 function addRemoteVideo (videoToCreateData, callback) {
   logger.debug('Adding remote video %s.', videoToCreateData.magnetUri)
 
-  // Mongoose pre hook will automatically create the thumbnail on disk
-  videoToCreateData.thumbnail = videoToCreateData.thumbnailBase64
-
   const video = new Video(videoToCreateData)
-  video.save(callback)
+  Video.generateThumbnailFromBase64(video, videoToCreateData.thumbnailBase64, function (err) {
+    if (err) {
+      logger.error('Cannot generate thumbnail from base 64 data.', { error: err })
+      return callback(err)
+    }
+
+    video.save(callback)
+  })
 }
 
 function removeRemoteVideo (videoToRemoveData, fromHost, callback) {