- const formData = new FormData()
- formData.append('name', name)
- // Put the video "private" -> we wait he validates the second step
- formData.append('privacy', VideoPrivacy.PRIVATE.toString())
- formData.append('nsfw', '' + nsfw)
- formData.append('commentsEnabled', '' + commentsEnabled)
- formData.append('channelId', '' + channelId)
- formData.append('videofile', videofile)
-
- this.isUploadingVideo = true
- this.form.patchValue({
- name,
- privacy,
- nsfw,
- channelId
- })
-
- this.videoService.uploadVideo(formData).subscribe(
- event => {
- if (event.type === HttpEventType.UploadProgress) {
- this.videoUploadPercents = Math.round(100 * event.loaded / event.total)
- } else if (event instanceof HttpResponse) {
- console.log('Video uploaded.')
-
- this.videoUploaded = true
-
- this.videoUploadedIds = event.body.video
- }
- },
-
- err => {
- // Reset progress
- this.videoUploadPercents = 0
- this.error = err.message
- }
- )