]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Upload a video to /videos/upload
authorChocobozzz <florian.bigard@gmail.com>
Thu, 7 Sep 2017 19:46:44 +0000 (21:46 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Thu, 7 Sep 2017 19:46:44 +0000 (21:46 +0200)
This is an action, not a REST endpoint

client/src/app/videos/video-edit/video-add.component.ts
server/controllers/api/videos/index.ts
server/tests/api/check-params/videos.ts
server/tests/cli/reset-password.ts
server/tests/cli/update-host.ts
server/tests/utils/videos.ts

index 768b6fbcdcc60963eb34c288be85a9988c7aa68c..42b11cd087eb24ee8b0bb1aa3e9eae6bb1443b4f 100644 (file)
@@ -95,7 +95,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
     this.uploader = new FileUploader({
       authToken: this.authService.getRequestHeaderValue(),
       queueLimit: 1,
-      url: API_URL + '/api/v1/videos',
+      url: API_URL + '/api/v1/videos/upload',
       removeAfterUpload: true
     })
 
@@ -166,7 +166,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
     }
 
     item.onError = (response: string, status: number) => {
-      // We need to handle manually these cases beceause we use the FileUpload component
+      // We need to handle manually these cases because we use the FileUpload component
       if (status === 400) {
         this.error = response
       } else if (status === 401) {
@@ -181,7 +181,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
       } else if (status === 403) {
         this.error = 'Your video quota is reached, you can\'t upload this video.'
       } else {
-        this.error = 'Unknow error'
+        this.error = 'Unknown error'
         console.error(this.error)
       }
     }
index 3ec9d97bb531aa1b274a12b5726e42cc645d8a74..3a19fe989b303a448145d846e11291cc2e26dafd 100644 (file)
@@ -92,7 +92,7 @@ videosRouter.put('/:id',
   videosUpdateValidator,
   updateVideoRetryWrapper
 )
-videosRouter.post('/',
+videosRouter.post('/upload',
   authenticate,
   reqFiles,
   videosAddValidator,
index 8d30769d3afff163bc04fe54cc36d871e5039c05..af75d33c1a9fc0dfaf76e0fdd5289a2ddb84ab6b 100644 (file)
@@ -96,7 +96,7 @@ describe('Test videos API validator', function () {
     it('Should fail with nothing', async function () {
       const fields = {}
       const attaches = {}
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail without name', async function () {
@@ -111,7 +111,7 @@ describe('Test videos API validator', function () {
       const attaches = {
         'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
       }
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail with a long name', async function () {
@@ -127,7 +127,7 @@ describe('Test videos API validator', function () {
       const attaches = {
         'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
       }
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail without a category', async function () {
@@ -142,7 +142,7 @@ describe('Test videos API validator', function () {
       const attaches = {
         'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
       }
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail with a bad category', async function () {
@@ -158,7 +158,7 @@ describe('Test videos API validator', function () {
       const attaches = {
         'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
       }
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail without a licence', async function () {
@@ -173,7 +173,7 @@ describe('Test videos API validator', function () {
       const attaches = {
         'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
       }
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail with a bad licence', async function () {
@@ -189,7 +189,7 @@ describe('Test videos API validator', function () {
       const attaches = {
         'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
       }
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail with a bad language', async function () {
@@ -205,7 +205,7 @@ describe('Test videos API validator', function () {
       const attaches = {
         'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
       }
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail without nsfw attribute', async function () {
@@ -220,7 +220,7 @@ describe('Test videos API validator', function () {
       const attaches = {
         'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
       }
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail with a bad nsfw attribue', async function () {
@@ -236,7 +236,7 @@ describe('Test videos API validator', function () {
       const attaches = {
         'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
       }
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail without description', async function () {
@@ -251,7 +251,7 @@ describe('Test videos API validator', function () {
       const attaches = {
         'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
       }
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail with a long description', async function () {
@@ -269,7 +269,7 @@ describe('Test videos API validator', function () {
       const attaches = {
         'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
       }
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail with too many tags', async function () {
@@ -285,7 +285,7 @@ describe('Test videos API validator', function () {
       const attaches = {
         'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
       }
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail with a tag length too low', async function () {
@@ -301,7 +301,7 @@ describe('Test videos API validator', function () {
       const attaches = {
         'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
       }
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail with a tag length too big', async function () {
@@ -317,7 +317,7 @@ describe('Test videos API validator', function () {
       const attaches = {
         'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
       }
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail without an input file', async function () {
@@ -331,7 +331,7 @@ describe('Test videos API validator', function () {
         tags: [ 'tag1', 'tag2' ]
       }
       const attaches = {}
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail without an incorrect input file', async function () {
@@ -347,7 +347,7 @@ describe('Test videos API validator', function () {
       const attaches = {
         'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
       }
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should fail with a too big duration', async function () {
@@ -363,7 +363,7 @@ describe('Test videos API validator', function () {
       const attaches = {
         'videofile': join(__dirname, '..', 'fixtures', 'video_too_long.webm')
       }
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
+      await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
     })
 
     it('Should succeed with the correct parameters', async function () {
@@ -382,13 +382,34 @@ describe('Test videos API validator', function () {
         'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm')
       }
 
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches, statusCodeExpected: 204 })
+      await makePostUploadRequest({
+        url: server.url,
+        path: path + '/upload',
+        token: server.accessToken,
+        fields,
+        attaches,
+        statusCodeExpected: 204
+      })
 
       attaches.videofile = join(__dirname, '..', 'fixtures', 'video_short.mp4')
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches, statusCodeExpected: 204 })
+      await makePostUploadRequest({
+        url: server.url,
+        path: path + '/upload',
+        token: server.accessToken,
+        fields,
+        attaches,
+        statusCodeExpected: 204
+      })
 
       attaches.videofile = join(__dirname, '..', 'fixtures', 'video_short.ogv')
-      await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches, statusCodeExpected: 204 })
+      await makePostUploadRequest({
+        url: server.url,
+        path: path + '/upload',
+        token: server.accessToken,
+        fields,
+        attaches,
+        statusCodeExpected: 204
+      })
     })
   })
 
index bbf0b3d113695b7c2b91599a00d09a8d9f5d9997..c75a1611c292f69386c1ff922ca3eddbaa986f36 100644 (file)
@@ -26,7 +26,7 @@ describe('Test reset password scripts', function () {
   })
 
   it('Should change the user password from CLI', async function () {
-    this.timeout(20000)
+    this.timeout(30000)
 
     const env = getEnvCli(server)
     await execCLI(`echo coucou | ${env} npm run reset-password -- -u user_1`)
index af9703b32053fb28aeda6902553728e8edac7622..644b3807e390dedacf0a3a14c9e11716716f6a48 100644 (file)
@@ -38,7 +38,7 @@ describe('Test update host scripts', function () {
   })
 
   it('Should update torrent hosts', async function () {
-    this.timeout(20000)
+    this.timeout(30000)
 
     killallServers([ server ])
     server = await runServer(1)
index 83271becabb95ffddcae5dabdb8d4fd44fbbf0b5..0de506cd91ee7a86d918669c9d7390ab57eddf68 100644 (file)
@@ -163,7 +163,7 @@ async function testVideoImage (url: string, imageName: string, imagePath: string
 }
 
 function uploadVideo (url: string, accessToken: string, videoAttributesArg: VideoAttributes, specialStatus = 204) {
-  const path = '/api/v1/videos'
+  const path = '/api/v1/videos/upload'
 
   // Default attributes
   let attributes = {