diff options
author | Chocobozzz <me@florianbigard.com> | 2022-04-19 14:25:33 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-04-19 14:25:33 +0200 |
commit | 33ac85bf610d74d353ee456a286159872cdd83cc (patch) | |
tree | bbd47ffebcdac4347b2b45a90898bd376f6a5211 /shared/server-commands/videos | |
parent | 77d0ae7b201264423d81e1019139eac3d7716536 (diff) | |
download | PeerTube-33ac85bf610d74d353ee456a286159872cdd83cc.tar.gz PeerTube-33ac85bf610d74d353ee456a286159872cdd83cc.tar.zst PeerTube-33ac85bf610d74d353ee456a286159872cdd83cc.zip |
Test digest check for resumable upload
Diffstat (limited to 'shared/server-commands/videos')
-rw-r--r-- | shared/server-commands/videos/videos-command.ts | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/shared/server-commands/videos/videos-command.ts b/shared/server-commands/videos/videos-command.ts index 2ac426f76..1cceb58db 100644 --- a/shared/server-commands/videos/videos-command.ts +++ b/shared/server-commands/videos/videos-command.ts | |||
@@ -482,8 +482,17 @@ export class VideosCommand extends AbstractCommand { | |||
482 | size: number | 482 | size: number |
483 | contentLength?: number | 483 | contentLength?: number |
484 | contentRangeBuilder?: (start: number, chunk: any) => string | 484 | contentRangeBuilder?: (start: number, chunk: any) => string |
485 | digestBuilder?: (chunk: any) => string | ||
485 | }) { | 486 | }) { |
486 | const { pathUploadId, videoFilePath, size, contentLength, contentRangeBuilder, expectedStatus = HttpStatusCode.OK_200 } = options | 487 | const { |
488 | pathUploadId, | ||
489 | videoFilePath, | ||
490 | size, | ||
491 | contentLength, | ||
492 | contentRangeBuilder, | ||
493 | digestBuilder, | ||
494 | expectedStatus = HttpStatusCode.OK_200 | ||
495 | } = options | ||
487 | 496 | ||
488 | const path = '/api/v1/videos/upload-resumable' | 497 | const path = '/api/v1/videos/upload-resumable' |
489 | let start = 0 | 498 | let start = 0 |
@@ -505,6 +514,10 @@ export class VideosCommand extends AbstractCommand { | |||
505 | 'Content-Length': contentLength ? contentLength + '' : chunk.length + '' | 514 | 'Content-Length': contentLength ? contentLength + '' : chunk.length + '' |
506 | } | 515 | } |
507 | 516 | ||
517 | if (digestBuilder) { | ||
518 | Object.assign(headers, { digest: digestBuilder(chunk) }) | ||
519 | } | ||
520 | |||
508 | const res = await got<{ video: VideoCreateResult }>({ | 521 | const res = await got<{ video: VideoCreateResult }>({ |
509 | url, | 522 | url, |
510 | method: 'put', | 523 | method: 'put', |