/** * Proxy for video uploads * * Will call the given video upload handler method (default: executeVideopostCall_FSOCK) * for the raw connection and send stuff * * @access public * @param string Local filename to be transfered * @param string Ticket * @return string VimeoVideosCheckUploadStatusResponse */ public function executeVideopostCall($sFilename, $sTicket = false) { // Check that the upload query handler method exists and can be called if (!method_exists(__CLASS__, self::VIDEOPOST_ENGINE_FSOCK)) { throw new VimeoUploadException('Upload error: Videopost engine handler method not found', 1); } // If permission requirement is not met refuse to even call the API, safes bandwith for both ends if (!self::checkPermission(VimeoBase::PERMISSION_WRITE)) { throw new VimeoUploadException('Upload error: Missing "write" permission for current user', 2); } // Check that the file exists if (!file_exists($sFilename)) { throw new VimeoUploadException('Upload error: Local file does not exists', 3); } // Check that the file is readable if (!is_readable($sFilename)) { throw new VimeoUploadException('Upload error: Local file is not readable', 4); } // Check that the file size is not larger then the allowed size you can upload $oResponse = VimeoPeopleRequest::getUploadStatus(); if (filesize($sFilename) > $oResponse->getRemainingBytes()) { throw new VimeoUploadException('Upload error: Videosize exceeds remaining bytes', 5); } // Try to get a upload ticket if (!$sTicket) { $oResponse = VimeoVideosRequest::getUploadTicket(); $sTicket = $oResponse->getTicket(); } // Build up the needed API arguments // Set API key $aArgs['api_key'] = self::$sApiKey; // Set request format $aArgs['format'] = 'php'; // Set token if (self::$sToken) { $aArgs['auth_token'] = self::$sToken; } // Set ticket $aArgs['ticket_id'] = $sTicket; // Generate signature $aArgs['api_sig'] = self::buildSignature($aArgs); // Set file $aArgs['file'] = "@{$sFilename}"; // Do the upload $sResponse = call_user_func(array(__CLASS__, self::VIDEOPOST_ENGINE_FSOCK), $aArgs); // Call vimeo.videos.checkUploadStatus to prevent abandoned status return VimeoVideosRequest::checkUploadStatus($sTicket); }