import { LoadingBarService } from '@ngx-loading-bar/core'
import { VideoPrivacy } from '@shared/models'
import { VideoSend } from './video-send'
+import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
@Component({
selector: 'my-video-upload',
}
formData: FormData
- waitTranscodingEnabled = true
previewfileUpload: File
error: string
let text = ''
if (this.videoUploaded === true) {
- // FIXME: cannot concatenate strings inside i18n service :/
+ // FIXME: cannot 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 {
cancelUpload () {
if (this.videoUploadObservable !== null) {
this.videoUploadObservable.unsubscribe()
+ }
- this.isUploadingVideo = false
- this.videoUploadPercents = 0
- this.videoUploadObservable = null
+ this.isUploadingVideo = false
+ this.videoUploadPercents = 0
+ this.videoUploadObservable = null
- this.firstStepError.emit()
- this.enableRetryAfterError = false
- this.error = ''
+ this.firstStepError.emit()
+ this.enableRetryAfterError = false
+ this.error = ''
- this.notifier.info($localize`Upload cancelled`)
- }
+ this.notifier.info($localize`Upload cancelled`)
}
uploadFirstStep (clickedOnButton = false) {
if (nameWithoutExtension.length < 3) name = videofile.name
else name = nameWithoutExtension
- // Force user to wait transcoding for unsupported video types in web browsers
- if (!videofile.name.endsWith('.mp4') && !videofile.name.endsWith('.webm') && !videofile.name.endsWith('.ogv')) {
- this.waitTranscodingEnabled = false
- }
-
const nsfw = this.serverConfig.instance.isNSFW
const waitTranscoding = true
const commentsEnabled = true
notifier: this.notifier,
sticky: false
})
+
+ if (err.status === HttpStatusCode.PAYLOAD_TOO_LARGE_413 ||
+ err.status === HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415) {
+ this.cancelUpload()
+ }
}
)
}