src/Vimeo/Vimeo.php
public function replace($video_uri, $file_path, array $params = array())
    {
        //  Validate that our file is real.
        if (!is_file($file_path)) {
            throw new VimeoUploadException('Unable to locate file to upload.');
        }

        $file_size = filesize($file_path);

        // Use JSON filtering so we only receive the data that we need to make an upload happen.
        $uri = $video_uri . self::VERSIONS_ENDPOINT . '?fields=upload';

        // Ignore any specified upload approach and size.
        $params['file_name'] = basename($file_path);
        $params['upload']['approach'] = 'tus';
        $params['upload']['size'] = $file_size;

        $attempt = $this->request($uri, $params, 'POST');
        if ($attempt['status'] !== 201) {
            $attempt_error = !empty($attempt['body']['error']) ? ' [' . $attempt['body']['error'] . ']' : '';
            throw new VimeoUploadException('Unable to initiate an upload.' . $attempt_error);
        }

        // `uri` doesn't come back from `/videos/:id/versions` so we need to manually set it here for uploading.
        $attempt['body']['uri'] = $video_uri;

        return $this->perform_upload_tus($file_path, $file_size, $attempt);
    }
public function replace($video_uri, $file_path, array $params = array())
    {
        //  Validate that our file is real.
        if (!is_file($file_path)) {
            throw new VimeoUploadException('Unable to locate file to upload.');
        }

        $file_size = filesize($file_path);

        // Use JSON filtering so we only receive the data that we need to make an upload happen.
        $uri = $video_uri . self::VERSIONS_ENDPOINT . '?fields=upload';

        // Ignore any specified upload approach and size.
        $params['file_name'] = basename($file_path);
        $params['upload']['approach'] = 'tus';
        $params['upload']['size'] = $file_size;

        $attempt = $this->request($uri, $params, 'POST');
        if ($attempt['status'] !== 201) {
            $attempt_error = !empty($attempt['body']['error']) ? ' [' . $attempt['body']['error'] . ']' : '';
            throw new VimeoUploadException('Unable to initiate an upload.' . $attempt_error);
        }

        // `uri` doesn't come back from `/videos/:id/versions` so we need to manually set it here for uploading.
        $attempt['body']['uri'] = $video_uri;

        return $this->perform_upload_tus($file_path, $file_size, $attempt);
    }
public function replace ( $ video_uri , $ file_path , array $ params = array ( ) ) { //  Validate that our file is real. if ( ! is_file ( $ file_path ) ) { throw new VimeoUploadException ( 'Unable to locate file to upload.' ) ; } $ file_size = filesize ( $ file_path ) ; // Use JSON filtering so we only receive the data that we need to make an upload happen. $ uri = $ video_uri . self :: VERSIONS_ENDPOINT . '?fields=upload' ; // Ignore any specified upload approach and size. $ params [ 'file_name' ] = basename ( $ file_path ) ; $ params [ 'upload' ] [ 'approach' ] = 'tus' ; $ params [ 'upload' ] [ 'size' ] = $ file_size ; $ attempt = $ this -> request ( $ uri , $ params , 'POST' ) ; if ( $ attempt [ 'status' ] !== 201 ) { $ attempt_error = ! empty ( $ attempt [ 'body' ] [ 'error' ] ) ? ' [' . $ attempt [ 'body' ] [ 'error' ] . ']' : '' ; throw new VimeoUploadException ( 'Unable to initiate an upload.' . $ attempt_error ) ; } // `uri` doesn't come back from `/videos/:id/versions` so we need to manually set it here for uploading. $ attempt [ 'body' ] [ 'uri' ] = $ video_uri ; return $ this -> perform_upload_tus ( $ file_path , $ file_size , $ attempt ) ; }
Replace the source of a single Vimeo video.

@link https://developer.vimeo.com/api/endpoints/videos#POST/videos/{video_id}/versions
@param string $video_uri Video uri of the video file to replace.
@param string $file_path Path to the video file to upload.
@return string Video URI
@throws VimeoRequestException
@throws VimeoUploadException
Replace the source of a single Vimeo video .