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) => {
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 {
onUploadVideoOngoing (state: UploadState) {
switch (state.status) {
- case 'error':
+ case 'error': {
const error = state.response?.error || 'Unknow error'
this.handleUploadError({
url: state.url
})
break
+ }
case 'cancelled':
this.isUploadingVideo = false
video.patch(this.form.value)
video.id = this.videoUploadedIds.id
video.uuid = this.videoUploadedIds.uuid
+ video.shortUUID = this.videoUploadedIds.shortUUID
this.isUpdatingVideo = true
this.updateVideoAndCaptions(video)
- .subscribe(
- () => {
+ .subscribe({
+ next: () => {
this.isUpdatingVideo = false
this.isUploadingVideo = false
this.router.navigateByUrl(Video.buildWatchUrl(video))
},
- err => {
+ error: err => {
this.error = err.message
scrollToTop()
console.error(err)
}
- )
+ })
}
private getInputVideoFile () {
const videoQuotaUsedBytes = bytePipes.transform(this.userVideoQuotaUsed, 0)
const videoQuotaBytes = bytePipes.transform(videoQuota, 0)
+ // eslint-disable-next-line max-len
const msg = $localize`Your video quota is exceeded with this video (video size: ${videoSizeBytes}, used: ${videoQuotaUsedBytes}, quota: ${videoQuotaBytes})`
this.notifier.error(msg)
const videoSizeBytes = bytePipes.transform(videofile.size, 0)
const quotaUsedDailyBytes = bytePipes.transform(this.userVideoQuotaUsedDaily, 0)
const quotaDailyBytes = bytePipes.transform(videoQuotaDaily, 0)
+ // eslint-disable-next-line max-len
const msg = $localize`Your daily video quota is exceeded with this video (video size: ${videoSizeBytes}, used: ${quotaUsedDailyBytes}, quota: ${quotaDailyBytes})`
this.notifier.error(msg)