aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-03 14:23:45 +0100
committerChocobozzz <me@florianbigard.com>2021-12-03 14:23:45 +0100
commit453537426a4e172967320cfac4bb1f53c28d94f5 (patch)
treee29f12f364a5e449c9edb6e011e6ca1d2a4f5857 /client/src
parente78acf81ff00568555e9823c1d9b01c7616b7272 (diff)
downloadPeerTube-453537426a4e172967320cfac4bb1f53c28d94f5.tar.gz
PeerTube-453537426a4e172967320cfac4bb1f53c28d94f5.tar.zst
PeerTube-453537426a4e172967320cfac4bb1f53c28d94f5.zip
Fix too long filename video upload
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts21
1 files changed, 18 insertions, 3 deletions
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
index 76205db44..28d7ec458 100644
--- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
+++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
@@ -1,4 +1,6 @@
1import { truncate } from 'lodash-es'
1import { UploadState, UploadxOptions, UploadxService } from 'ngx-uploadx' 2import { UploadState, UploadxOptions, UploadxService } from 'ngx-uploadx'
3import { isIOS } from 'src/assets/player/utils'
2import { HttpErrorResponse, HttpEventType, HttpHeaders } from '@angular/common/http' 4import { HttpErrorResponse, HttpEventType, HttpHeaders } from '@angular/common/http'
3import { AfterViewInit, Component, ElementRef, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core' 5import { AfterViewInit, Component, ElementRef, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'
4import { Router } from '@angular/router' 6import { Router } from '@angular/router'
@@ -10,7 +12,6 @@ import { LoadingBarService } from '@ngx-loading-bar/core'
10import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' 12import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models'
11import { UploaderXFormData } from './uploaderx-form-data' 13import { UploaderXFormData } from './uploaderx-form-data'
12import { VideoSend } from './video-send' 14import { VideoSend } from './video-send'
13import { isIOS } from 'src/assets/player/utils'
14 15
15@Component({ 16@Component({
16 selector: 'my-video-upload', 17 selector: 'my-video-upload',
@@ -281,6 +282,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
281 channelId: this.firstStepChannelId, 282 channelId: this.firstStepChannelId,
282 nsfw: this.serverConfig.instance.isNSFW, 283 nsfw: this.serverConfig.instance.isNSFW,
283 privacy: this.highestPrivacy.toString(), 284 privacy: this.highestPrivacy.toString(),
285 name: this.buildVideoFilename(file.name),
284 filename: file.name, 286 filename: file.name,
285 previewfile: previewfile as any 287 previewfile: previewfile as any
286 } 288 }
@@ -311,8 +313,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
311 } 313 }
312 314
313 private closeFirstStep (filename: string) { 315 private closeFirstStep (filename: string) {
314 const nameWithoutExtension = filename.replace(/\.[^/.]+$/, '') 316 const name = this.buildVideoFilename(filename)
315 const name = nameWithoutExtension.length < 3 ? filename : nameWithoutExtension
316 317
317 this.form.patchValue({ 318 this.form.patchValue({
318 name, 319 name,
@@ -369,4 +370,18 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
369 370
370 return extensions.some(e => filename.endsWith(e)) 371 return extensions.some(e => filename.endsWith(e))
371 } 372 }
373
374 private buildVideoFilename (filename: string) {
375 const nameWithoutExtension = filename.replace(/\.[^/.]+$/, '')
376 let name = nameWithoutExtension.length < 3
377 ? filename
378 : nameWithoutExtension
379
380 const videoNameMaxSize = 110
381 if (name.length > videoNameMaxSize) {
382 name = truncate(name, { length: videoNameMaxSize, omission: '' })
383 }
384
385 return name
386 }
372} 387}