import { FormValidatorService } from '@app/shared/shared-forms'
import { BytesPipe, Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main'
import { LoadingBarService } from '@ngx-loading-bar/core'
-import { HttpStatusCode, VideoPrivacy } from '@shared/models'
+import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models'
import { UploaderXFormData } from './uploaderx-form-data'
import { VideoSend } from './video-send'
+import { isIOS } from 'src/assets/player/utils'
@Component({
selector: 'my-video-upload',
videoUploaded = false
videoUploadPercents = 0
- videoUploadedIds = {
+ videoUploadedIds: VideoCreateResult = {
id: 0,
- uuid: ''
+ uuid: '',
+ shortUUID: ''
}
formData: FormData
) {
super()
+ // FIXME: https://github.com/Chocobozzz/PeerTube/issues/4382#issuecomment-915854167
+ const chunkSize = isIOS()
+ ? 0
+ : undefined // Auto chunk size
+
this.uploadxOptions = {
endpoint: this.BASE_VIDEO_UPLOAD_URL,
multiple: false,
token: this.authService.getAccessToken(),
uploaderClass: UploaderXFormData,
+ chunkSize,
retryConfig: {
- maxAttempts: 6,
- shouldRetry: (code: number) => {
- return code < 400 || code >= 501
+ maxAttempts: 30, // maximum attempts for 503 codes, otherwise set to 6, see below
+ maxDelay: 120_000, // 2 min
+ shouldRetry: (code: number, attempts: number) => {
+ return code === HttpStatusCode.SERVICE_UNAVAILABLE_503 || ((code < 400 || code > 500) && attempts < 6)
}
}
}
let text = ''
if (this.videoUploaded === true) {
- // FIXME: cannot concatenate strings using $localize
+ // We can't concatenate strings using $localize
text = $localize`Your video was uploaded to your account and is private.` + ' ' +
$localize`But associated data (tags, description...) will be lost, are you sure you want to leave this page?`
} else {
video.patch(this.form.value)
video.id = this.videoUploadedIds.id
video.uuid = this.videoUploadedIds.uuid
+ video.shortUUID = this.videoUploadedIds.shortUUID
this.isUpdatingVideo = true