Angular4, Simple Video Upload Recording, Vimeo API,

I have a one page web app creation in Angular v4 as a CMS for Vimeo, I have a column working and editing metadata, but cannot solve the video upload with a simple post method as described in the API.

I call "getUploadTicket" in ngOnInit and showing upload_secure_link in DOM so I know there is, then "uploadPostMethod" function below is called in submit button in HTML, file is defined with "fileChangeEvent"

getUploadTicket(): Promise<Video> {
return this.http.post('https://api.vimeo.com/me/videos' + this.token, this.headersX)
.toPromise()
.then(response => response.json() as Video)
.catch(this.handleErrorPromise);
}

fileChangeEvent(fileInput: any) {
this.filesToUpload = fileInput.target.files;
let file: File = this.filesToUpload[0];
}

uploadPostMethod(url): any {
let file: File = this.filesToUpload[0];
console.log(JSON.stringify(url));
return this.http.post(url,file,this.headersPost)
  .map((response) => {
    let data = response.text() ? response.json() : [{}];
    if (data) {
      console.log('returned after post video file to upload' + JSON.stringify(data));
    }
    return JSON.stringify(data);
  })

      

}

my html:

    {{video.uri}}<br>
    {{video.upload_link_secure}}<br>
    {{video.ticket_id}}<br>
    {{video.form}}<br>


    <input type="file" (change)="fileChangeEvent($event)" placeholder="Select file" accept="video/mp4"/>
    <br><br>
    <button style="width: 100%" class="mdl-button" (click)="uploadPostMethod(video.upload_link_secure)">Upload Video</button>

      

But I just don't get any permission on upload - the file size is small at 966469 bytes, any help or syntax points in Angular would be much appreciated. I am not using vimeo libraries. - I had some success with postman once I removed the redirecturl paramater from upload_secure_link, but now it's a flop - the access token is valid and working. (angular 4, CLI, Vimeo API)

+3


source to share





All Articles