diff options
-rw-r--r-- | client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts | 21 | ||||
-rw-r--r-- | server/middlewares/validators/videos/videos.ts | 2 |
2 files changed, 19 insertions, 4 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 @@ | |||
1 | import { truncate } from 'lodash-es' | ||
1 | import { UploadState, UploadxOptions, UploadxService } from 'ngx-uploadx' | 2 | import { UploadState, UploadxOptions, UploadxService } from 'ngx-uploadx' |
3 | import { isIOS } from 'src/assets/player/utils' | ||
2 | import { HttpErrorResponse, HttpEventType, HttpHeaders } from '@angular/common/http' | 4 | import { HttpErrorResponse, HttpEventType, HttpHeaders } from '@angular/common/http' |
3 | import { AfterViewInit, Component, ElementRef, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core' | 5 | import { AfterViewInit, Component, ElementRef, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core' |
4 | import { Router } from '@angular/router' | 6 | import { Router } from '@angular/router' |
@@ -10,7 +12,6 @@ import { LoadingBarService } from '@ngx-loading-bar/core' | |||
10 | import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' | 12 | import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' |
11 | import { UploaderXFormData } from './uploaderx-form-data' | 13 | import { UploaderXFormData } from './uploaderx-form-data' |
12 | import { VideoSend } from './video-send' | 14 | import { VideoSend } from './video-send' |
13 | import { 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 | } |
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index 4916decbf..3ebdbc33d 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts | |||
@@ -211,7 +211,7 @@ const videosAddResumableInitValidator = getCommonVideoEditAttributes().concat([ | |||
211 | const videoFileMetadata = { | 211 | const videoFileMetadata = { |
212 | mimetype: req.headers['x-upload-content-type'] as string, | 212 | mimetype: req.headers['x-upload-content-type'] as string, |
213 | size: +req.headers['x-upload-content-length'], | 213 | size: +req.headers['x-upload-content-length'], |
214 | originalname: req.body.name | 214 | originalname: req.body.filename |
215 | } | 215 | } |
216 | 216 | ||
217 | const user = res.locals.oauth.token.User | 217 | const user = res.locals.oauth.token.User |