- 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('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.videoUploadedId = event.body.video.id
- }
- },
-
- err => {
- // Reset progress
- this.videoUploadPercents = 0
- this.error = err.message
- }
- )