in frontend/src/app/return-service/upload-image/upload-image.component.ts [105:151]
async videoUploadtoGCS(videoInput: any): Promise<any> {
this.uploadingVideo = true;
const file: File = videoInput.files[0];
return await this.firebaseService.uploadReturnItemVideoToStorage(file).then((snapshot) => {
this.firebaseService.returnItemVideoURL(snapshot.metadata.name).then(
(url) => {
let gcsurl = 'gs://rl-llm-dev.appspot.com/' + snapshot.metadata.fullPath
console.log("gcs video url", gcsurl);
const reader = new FileReader();
reader.addEventListener('load', () => {
let base64string = reader.result as string;
this.videoSource = this.sanitizer.bypassSecurityTrustResourceUrl(base64string);
this.videoPreview = this.videoSource.changingThisBreaksApplicationSecurity
this.videoSource = this.videoSource.changingThisBreaksApplicationSecurity.split(',')[1]
this.videoUploaded = true;
this.validationInprogress = true;
this.returnService.returnValidation(this.returnItem.image, "", gcsurl).subscribe({
next: (data: any) => {
this.uploadingVideo = false;
this.validationInprogress = false;
this.returnItem.return_metadata = {
image_uploaded: "",
video_uploaded: gcsurl,
is_valid: data.valid,
ai_validation_reason: data.reasoning,
return_status: 'under review',
return_type: data.return_type,
returned_date: this.returnService.getYYYYMMDD(this.today),
}
if (data.valid) {
this.showAlternateProducts = true;
} else {
this.updateOrder(data, "", url);
}
},
error: (error) => {
this.uploadingVideo = false;
this.validationInprogress = false;
throw error;
}
});
});
reader.readAsDataURL(file);
}
)
});
}