]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/server-commands/videos/videos-command.ts
Translated using Weblate (French (France) (fr_FR))
[github/Chocobozzz/PeerTube.git] / shared / server-commands / videos / videos-command.ts
index 8ea828b40dbc13ffb723d6594451ace77d1740e5..1cceb58dbd3b259d6ceb264ccbbbc14afb4b5186 100644 (file)
@@ -5,8 +5,8 @@ import { createReadStream, stat } from 'fs-extra'
 import got, { Response as GotResponse } from 'got'
 import { omit } from 'lodash'
 import validator from 'validator'
-import { buildUUID } from '@shared/core-utils/uuid'
-import { pick } from '@shared/core-utils'
+import { buildAbsoluteFixturePath, pick, wait } from '@shared/core-utils'
+import { buildUUID } from '@shared/extra-utils'
 import {
   HttpStatusCode,
   ResultList,
@@ -20,7 +20,6 @@ import {
   VideosCommonQuery,
   VideoTranscodingCreate
 } from '@shared/models'
-import { buildAbsoluteFixturePath, wait } from '../miscs'
 import { unwrapBody } from '../requests'
 import { waitJobs } from '../server'
 import { AbstractCommand, OverrideCommandOptions } from '../shared'
@@ -108,23 +107,6 @@ export class VideosCommand extends AbstractCommand {
 
   // ---------------------------------------------------------------------------
 
-  view (options: OverrideCommandOptions & {
-    id: number | string
-    xForwardedFor?: string
-  }) {
-    const { id, xForwardedFor } = options
-    const path = '/api/v1/videos/' + id + '/views'
-
-    return this.postBodyRequest({
-      ...options,
-
-      path,
-      xForwardedFor,
-      implicitToken: false,
-      defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
-    })
-  }
-
   rate (options: OverrideCommandOptions & {
     id: number | string
     rating: UserVideoRateType
@@ -500,8 +482,17 @@ export class VideosCommand extends AbstractCommand {
     size: number
     contentLength?: number
     contentRangeBuilder?: (start: number, chunk: any) => string
+    digestBuilder?: (chunk: any) => string
   }) {
-    const { pathUploadId, videoFilePath, size, contentLength, contentRangeBuilder, expectedStatus = HttpStatusCode.OK_200 } = options
+    const {
+      pathUploadId,
+      videoFilePath,
+      size,
+      contentLength,
+      contentRangeBuilder,
+      digestBuilder,
+      expectedStatus = HttpStatusCode.OK_200
+    } = options
 
     const path = '/api/v1/videos/upload-resumable'
     let start = 0
@@ -523,6 +514,10 @@ export class VideosCommand extends AbstractCommand {
           'Content-Length': contentLength ? contentLength + '' : chunk.length + ''
         }
 
+        if (digestBuilder) {
+          Object.assign(headers, { digest: digestBuilder(chunk) })
+        }
+
         const res = await got<{ video: VideoCreateResult }>({
           url,
           method: 'put',