troubleshooting Question

Regarding issue on passing endpoint into angularjs

Avatar of roy_sanu
roy_sanuFlag for India asked on
Angular
10 Comments1 Solution194 ViewsLast Modified:
Hello experts,

I have an  endpoint  API  below which checks the inappropriate content in a video

POST 'https://api.sightengine.com/1.0/moderation.json' 
 'api_user={api_user}' \
 'api_secret={api_secret}' \
 'media=@/path/to/local/file.jpg'

I want to pass this  above endpoint API  mark below  space  of my comments through angularjs application which can verify the uploaded file with the inappropriate content in it.let us know through the snippet of code… Pls find my code  below





export class VideoUploadService {
  public videup: VideoUpload;
  constructor(private http: Http, private router: Router, @Inject('videoUploadEndPoint') private videoUploadUrl) { }
  requestUrl: string;
  responseData: any;
  //handleError: any;
  postVideoData(file: any, title: any, videoCatgy: any, country: any, language: any, starttime: any, endtime: any, duration: any) {
    var formData: any = new FormData();
    formData.append("uploadFileName", file, file.name);//alert(file.name);

   // verifying the video content with Sightengine  endpoint from here onwards. Let us   
    know..



formData.append('videoTitle', title);
 formData.append('videoCatgy', videoCatgy);
 formData.append('userName', 'testuser');
 formData.append('startTmName', starttime);
 formData.append('endTmName', endtime);
 formData.append('durClpName', duration);
  var returnReponse = new Promise((resolve, reject) => {
     this.http.post(this.videoUploadUrl + 'videoclip/', formData, {
        // headers: headers
      }).subscribe(
        res => {//console.log(res.json());

          this.responseData = res.json();
          resolve(this.responseData);
          this.router.navigate(['']);
        },
        error => {
          this.router.navigate(['']);
          reject(error);
        }
        );
    });

  }
  private extractData(res: Response) {
    let body = res.json();

    return body || {};
  }

  private handleError(error: Response | any) {
    let errMsg: string;
    if (error instanceof Response) {
      const body = error.json() || '';
      const err = body.error || JSON.stringify(body);
      errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
    } else {
      errMsg = error.message ? error.message : error.toString();
    }
    console.error(errMsg);
    return Observable.throw(errMsg);
  }

} 
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros