Trying to get Vimeo API to recognize the upload file

Viewed 139

I am using Expo managed Workflow with react-native and trying desperately to not have to eject. The only sticking point in the entire app is allowing users of the app to upload video into a usable format. I am hoping to use Vimeo as the video hosting service.

I am authenticated and verified and interacting with the Vimeo API.

On my express server when I run this code:

let Vimeo = require('vimeo').Vimeo;
let client = new Vimeo({vimeo creds});

client.request({
  method: 'GET',
  path: '/tutorial'
}, function (error, body, status_code, headers) {
  if (error) {
    console.log(error);
  }
  console.log(body);
})

I see this message:

message: 'Success! You just interacted with the Vimeo API. Your dev environment is configured correctly, and the client ID, client secret, and access token that you provided are all working fine.',
next_steps_link: 'https://developer.vimeo.com/api/guides/videos/upload',
token_is_authenticated: true

I successfully uploaded a video from my express server using this code and placing the file on the same directory as the server code.

client.upload(

"{filename}",
{
  'name': ' Test Video 1',
  'description': 'The description goes here.'
},
function (uri) {
  console.log('Your video URI is: ' + uri);
},
function (bytes_uploaded, bytes_total) {
  var percentage = (bytes_uploaded / bytes_total * 100).toFixed(2)
  console.log(bytes_uploaded, bytes_total, percentage + '%')
},
function (error) {
  console.log('Failed because: ' + error)
}
)

Then, I added the same functionality to my web app locally for testing but not on an express server, trying to do it within a react native app running in a browser (for starters). I still get the message that says I am successfully interacting with Vimeo API and that I am authenticated.

However, When I try to add the file in the react native app with the exact same code, except this is how I am accessing the video file from react native: filename = require({pathToFile});

and the failed response says:

"Failed because: Unable to locate file to upload."

I do not know if the message is incorrect and if Vimeo API is having issues understanding the file or if it could be that because I am no longer running on a server.

So I keep trying to make sense of how to do this but wonder if I am missing something at this stage of testing.

Because...

I am able to upload the video to Firebase Storage by using expo-image-picker.

When I try to give the Vimeo API the file from what I have retrieved from the filesystem, it still says it is unable to locate file to upload.

In this case the string I am trying to upload looks like this: data:video/quicktime;base64,AAAAHGZ0eXBtcDQyAAAAAW…5AQLMKwEjd8ABNvCVAUgYoQFR1yYBVZYxAVX9NwFXEy8BYh0m

Any suggestions of a way to get Vimeo api to recognize this file?

I really want to use Vimeo for this project I can't find anything on stack overflow related to this except this one question which noone has attempted to answer:

Failed because: Unable to locate file to upload but path is correct (Vimeo API)

0 Answers
Related