May 27, 2020
0
Level 10
Someone could give me an advice on the vimeo laravel bridge package
I know it is no really laravel related, but maybe some could help me anyway. My problem is I feel a little bit uncomfortable with the vimeo api I am not sure if this is clean code. I wrote code to create a folder if it does not exist and then move the uploaded file into that folder. Package https://github.com/vimeo/laravel. It looks like
$folder = Vimeo::request('/me/projects/', ['name' => $subtopic->slug], 'GET');
if($folder['body']['total'] > 0) {
$vimeo_folder_uri = $folder['body']['data'][0]['uri'];
}
if($folder['body']['total'] == 0) {
$vimeo_folder_uri = Vimeo::request('/me/projects/', ['name' => $subtopic->slug],'POST');
$vimeo_folder_uri = $vimeo_folder_uri['body']['uri'];
}
$uri = Vimeo::upload($file, ['name' => $request->title], 'POST');
Vimeo::request($vimeo_folder_uri . $uri, ['name' => $subtopic->slug],'PUT');
$vimeo_id = str_replace("/videos/", "", $uri);
This look a little bit unhandy and not very clean, maybe someone could give me advice if it needs refactoring.
Please or to participate in this conversation.