aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos/index.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-10 14:34:45 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:51 +0100
commit0d0e8dd0904b380b70e19ebcb4763d65601c4632 (patch)
treeacb625d7c88fbe863fa14bf6783fafe4a8e35137 /server/controllers/api/videos/index.ts
parente4f97babf701481b55cc10fb3448feab5f97c867 (diff)
downloadPeerTube-0d0e8dd0904b380b70e19ebcb4763d65601c4632.tar.gz
PeerTube-0d0e8dd0904b380b70e19ebcb4763d65601c4632.tar.zst
PeerTube-0d0e8dd0904b380b70e19ebcb4763d65601c4632.zip
Continue activitypub
Diffstat (limited to 'server/controllers/api/videos/index.ts')
-rw-r--r--server/controllers/api/videos/index.ts30
1 files changed, 16 insertions, 14 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 4dd09917b..964db151d 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -10,7 +10,8 @@ import {
10 VIDEO_CATEGORIES, 10 VIDEO_CATEGORIES,
11 VIDEO_LICENCES, 11 VIDEO_LICENCES,
12 VIDEO_LANGUAGES, 12 VIDEO_LANGUAGES,
13 VIDEO_PRIVACIES 13 VIDEO_PRIVACIES,
14 VIDEO_MIMETYPE_EXT
14} from '../../../initializers' 15} from '../../../initializers'
15import { 16import {
16 addEventToRemoteVideo, 17 addEventToRemoteVideo,
@@ -50,6 +51,7 @@ import { abuseVideoRouter } from './abuse'
50import { blacklistRouter } from './blacklist' 51import { blacklistRouter } from './blacklist'
51import { rateVideoRouter } from './rate' 52import { rateVideoRouter } from './rate'
52import { videoChannelRouter } from './channel' 53import { videoChannelRouter } from './channel'
54import { getActivityPubUrl } from '../../../helpers/activitypub'
53 55
54const videosRouter = express.Router() 56const videosRouter = express.Router()
55 57
@@ -59,19 +61,18 @@ const storage = multer.diskStorage({
59 cb(null, CONFIG.STORAGE.VIDEOS_DIR) 61 cb(null, CONFIG.STORAGE.VIDEOS_DIR)
60 }, 62 },
61 63
62 filename: (req, file, cb) => { 64 filename: async (req, file, cb) => {
63 let extension = '' 65 const extension = VIDEO_MIMETYPE_EXT[file.mimetype]
64 if (file.mimetype === 'video/webm') extension = 'webm' 66 let randomString = ''
65 else if (file.mimetype === 'video/mp4') extension = 'mp4' 67
66 else if (file.mimetype === 'video/ogg') extension = 'ogv' 68 try {
67 generateRandomString(16) 69 randomString = await generateRandomString(16)
68 .then(randomString => { 70 } catch (err) {
69 cb(null, randomString + '.' + extension) 71 logger.error('Cannot generate random string for file name.', err)
70 }) 72 randomString = 'fake-random-string'
71 .catch(err => { 73 }
72 logger.error('Cannot generate random string for file name.', err) 74
73 throw err 75 cb(null, randomString + '.' + extension)
74 })
75 } 76 }
76}) 77})
77 78
@@ -190,6 +191,7 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi
190 channelId: res.locals.videoChannel.id 191 channelId: res.locals.videoChannel.id
191 } 192 }
192 const video = db.Video.build(videoData) 193 const video = db.Video.build(videoData)
194 video.url = getActivityPubUrl('video', video.uuid)
193 195
194 const videoFilePath = join(CONFIG.STORAGE.VIDEOS_DIR, videoPhysicalFile.filename) 196 const videoFilePath = join(CONFIG.STORAGE.VIDEOS_DIR, videoPhysicalFile.filename)
195 const videoFileHeight = await getVideoFileHeight(videoFilePath) 197 const videoFileHeight = await getVideoFileHeight(videoFilePath)