vimeo / vimeo.js

Official Node.js library for the Vimeo API.
https://developer.vimeo.com
Apache License 2.0
267 stars 78 forks source link

Upload videos from an SPA (Angular 12) - Which is the best approach? #149

Closed mberiam closed 2 years ago

mberiam commented 2 years ago

Hi! I am having a problem uploading a video from an Angular 12 application. I was trying to use the JS library provided by Vimeo, but it is not working due to a dependency on the fs.js lib, which Angular claims not to be able to run on the client side, only server side (with nodejs, for example). I would like support for uploading from an Angular application. Does Vimeo offer an API so I can connect to any endpoints and send the bytes and the file metadata? Worth quoting I also tried to use that approach of making a POST with the metadata and the subsequent upload of the video, using the form provided as the return from the first POST, but Angular also doesn't support a form with an action for another page, as it's a single page application (SPA). Is there any documentation that teaches the dev team to integrate the SPA and Vimeo, after all this kind of application is really common nowadays. Thanks in advance

aaronm67 commented 2 years ago

This is the API documentation you're looking for:

https://developer.vimeo.com/api/upload/videos#form-based-approach-step-2

Form based is probably the easiest to integrate with what you're looking for.

mberiam commented 2 years ago

Thanks for your response. But it is the approach I had mentioned - it did not work inside a single page application. I cannot inject a form as in a standard HTML site. The form has an action, which redirects the app to another page. As it is a single page application, there is no such a thing as "after post page". Is there a way to post to that endpoint/web address using an ajax approach?

aaronm67 commented 2 years ago

You can add any javascript handlers as desired to the form returned from POST /me/videos, it doesn't need to do a full reload.

You can also use the TUS approach (documented right above the form approach), this isn't ideal client-side, though.