public static function fromUploadTokenArray($arr) { $newArr = new KalturaUploadTokenArray(); foreach ($arr as $obj) { $nObj = new KalturaUploadToken(); $nObj->fromObject($obj); $newArr[] = $nObj; } return $newArr; }
public static function fromDbArray(array $arr, KalturaDetachedResponseProfile $responseProfile = null) { $newArr = new KalturaUploadTokenArray(); foreach ($arr as $obj) { $nObj = new KalturaUploadToken(); $nObj->fromObject($obj, $responseProfile); $newArr[] = $nObj; } return $newArr; }
function add(KalturaUploadToken $uploadToken = null) { $kparams = array(); if ($uploadToken !== null) { $this->client->addParam($kparams, "uploadToken", $uploadToken->toParams()); } $this->client->queueServiceActionCall("uploadtoken", "add", $kparams); if ($this->client->isMultiRequest()) { return null; } $resultObject = $this->client->doQueue(); $this->client->throwExceptionIfError($resultObject); $this->client->validateObjectType($resultObject, "KalturaUploadToken"); return $resultObject; }
/** * Upload a file using the upload token id, returns an error on failure (an exception will be thrown when using one of the Kaltura clients) * * @action upload * @param string $uploadTokenId * @param file $fileData * @param bool $resume * @param bool $finalChunk * @param float $resumeAt * @return KalturaUploadToken */ function uploadAction($uploadTokenId, $fileData, $resume = false, $finalChunk = true, $resumeAt = -1) { $this->restrictPeerToCurrentUser(); $uploadTokenDb = UploadTokenPeer::retrieveByPK($uploadTokenId); if (is_null($uploadTokenDb)) { throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_NOT_FOUND); } // if the token was generated on another datacenter, proxy the upload action there $remoteDCHost = kUploadTokenMgr::getRemoteHostForUploadToken($uploadTokenId, kDataCenterMgr::getCurrentDcId()); if ($remoteDCHost) { kFile::dumpApiRequest($remoteDCHost); } $uploadTokenMgr = new kUploadTokenMgr($uploadTokenDb); try { $uploadTokenMgr->uploadFileToToken($fileData, $resume, $finalChunk, $resumeAt); } catch (kUploadTokenException $ex) { switch ($ex->getCode()) { case kUploadTokenException::UPLOAD_TOKEN_INVALID_STATUS: throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_INVALID_STATUS_FOR_UPLOAD); case kUploadTokenException::UPLOAD_TOKEN_FILE_NAME_IS_MISSING_FOR_UPLOADED_FILE: case kUploadTokenException::UPLOAD_TOKEN_UPLOAD_ERROR_OCCURRED: case kUploadTokenException::UPLOAD_TOKEN_FILE_IS_NOT_VALID: throw new KalturaAPIException(KalturaErrors::UPLOAD_ERROR); case kUploadTokenException::UPLOAD_TOKEN_FILE_NOT_FOUND_FOR_RESUME: throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_CANNOT_RESUME); case kUploadTokenException::UPLOAD_TOKEN_RESUMING_NOT_ALLOWED: throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_RESUMING_NOT_ALLOWED); case kUploadTokenException::UPLOAD_TOKEN_RESUMING_INVALID_POSITION: throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_RESUMING_INVALID_POSITION); default: throw $ex; } } $uploadToken = new KalturaUploadToken(); $uploadToken->fromObject($uploadTokenDb); return $uploadToken; }