"request": "^2.57.0",
"request-replay": "^1.0.2",
"rimraf": "^2.5.4",
+ "safe-buffer": "^5.0.1",
"scripty": "^1.5.0",
"sequelize": "^3.27.0",
"ursa": "^0.9.1",
},
function generateThumbnail (t, tagInstances, video, callback) {
- db.Video.generateThumbnailFromBase64(video, videoToCreateData.thumbnailBase64, function (err) {
+ db.Video.generateThumbnailFromData(video, videoToCreateData.thumbnailData, function (err) {
if (err) {
- logger.error('Cannot generate thumbnail from base 64 data.', { error: err })
+ logger.error('Cannot generate thumbnail from data.', { error: err })
return callback(err)
}
'use strict'
-const each = require('async/each')
const express = require('express')
const waterfall = require('async/waterfall')
const constants = require('../../initializers/constants')
const db = require('../../initializers/database')
-const friends = require('../../lib/friends')
const logger = require('../../helpers/logger')
const middlewares = require('../../middlewares')
const admin = middlewares.admin
isVideoNameValid,
isVideoTagsValid,
isVideoThumbnailValid,
- isVideoThumbnail64Valid
+ isVideoThumbnailDataValid
}
function isEachRemoteVideosValid (requests) {
isVideoInfoHashValid(video.infoHash) &&
isVideoNameValid(video.name) &&
isVideoTagsValid(video.tags) &&
- isVideoThumbnail64Valid(video.thumbnailBase64) &&
+ isVideoThumbnailDataValid(video.thumbnailData) &&
isVideoRemoteIdValid(video.remoteId) &&
isVideoExtnameValid(video.extname)
) ||
return validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.THUMBNAIL)
}
-function isVideoThumbnail64Valid (value) {
- return validator.isBase64(value) &&
- validator.isByteLength(value, VIDEOS_CONSTRAINTS_FIELDS.THUMBNAIL64)
+function isVideoThumbnailDataValid (value) {
+ return validator.isByteLength(value, VIDEOS_CONSTRAINTS_FIELDS.THUMBNAIL_DATA)
}
function isVideoRemoteIdValid (value) {
TAGS: { min: 1, max: 3 }, // Number of total tags
TAG: { min: 2, max: 10 }, // Length
THUMBNAIL: { min: 2, max: 30 },
- THUMBNAIL64: { min: 0, max: 20000 } // Bytes
+ THUMBNAIL_DATA: { min: 0, max: 20000 } // Bytes
}
}
'use strict'
+const Buffer = require('safe-buffer').Buffer
const createTorrent = require('create-torrent')
const ffmpeg = require('fluent-ffmpeg')
const fs = require('fs')
classMethods: {
associate,
- generateThumbnailFromBase64,
+ generateThumbnailFromData,
getDurationFromFile,
list,
listForApi,
function toRemoteJSON (callback) {
const self = this
- // Convert thumbnail to base64
+ // Get thumbnail data to send to the other pod
const thumbnailPath = pathUtils.join(constants.CONFIG.STORAGE.THUMBNAILS_DIR, this.getThumbnailName())
fs.readFile(thumbnailPath, function (err, thumbnailData) {
if (err) {
remoteId: self.id,
author: self.Author.name,
duration: self.duration,
- thumbnailBase64: new Buffer(thumbnailData).toString('base64'),
+ thumbnailData: thumbnailData.toString('binary'),
tags: map(self.Tags, 'name'),
createdAt: self.createdAt,
extname: self.extname
// ------------------------------ STATICS ------------------------------
-function generateThumbnailFromBase64 (video, thumbnailData, callback) {
+function generateThumbnailFromData (video, thumbnailData, callback) {
// Creating the thumbnail for a remote video
const thumbnailName = video.getThumbnailName()
const thumbnailPath = constants.CONFIG.STORAGE.THUMBNAILS_DIR + thumbnailName
- fs.writeFile(thumbnailPath, thumbnailData, { encoding: 'base64' }, function (err) {
+ fs.writeFile(thumbnailPath, Buffer.from(thumbnailData, 'binary'), function (err) {
if (err) return callback(err)
return callback(null, thumbnailName)