onFileChange()

in frontend/src/app/social-media-post/social-media-post.component.ts [336:365]


  onFileChange(pFileList: File[]) {
    this.showProgress = true;
    let selectedCampaign: any
    selectedCampaign = this.CAMPAIGN_DATA1.filter((a: any) => a.id === this.selectedCampaignId)
    this.fileUploaded = true;
    const reader = new FileReader();

    this.campaignServ.imageUpload(pFileList[0], selectedCampaign[0].data?.workspace_assets?.new_folder_id, event).subscribe((res: any) => {
      reader.addEventListener('load', (event: any) => {
        this.imageSrc = event.target.result;
        this.images.push({ id: 1, image: this.imageSrc });
        this.showImagesUploaded = true;
        this.showImageSection = true;
        this.showPostSection = false;
      });
      reader.readAsDataURL(pFileList[0]);

      this.imageGcsPath = res;
      // this.editImageSection = true;
      this.files = Object.keys(pFileList).map((key: any) => pFileList[key]);
      this.showProgress = false;

      //this.showGenarateImagedata = true;
      this.showGenarateImageEmaildata = true;
      this.snackBar.open("Successfully upload!", 'Close', {
        duration: 2000,
      });
    })

  }