/** * @action addCategories * @actionAlias category.addFromBulkUpload * * Action adds categories from a bulkupload CSV file * @param file $fileData * @param KalturaBulkUploadJobData $bulkUploadData * @param KalturaBulkUploadCategoryData $bulkUploadCategoryData * @return KalturaBulkUpload */ public function addCategoriesAction($fileData, KalturaBulkUploadJobData $bulkUploadData = null, KalturaBulkUploadCategoryData $bulkUploadCategoryData = null) { if (!$bulkUploadData) { $bulkUploadData = KalturaPluginManager::loadObject('KalturaBulkUploadJobData', null); } if (!$bulkUploadCategoryData) { $bulkUploadCategoryData = new KalturaBulkUploadCategoryData(); } if (!$bulkUploadData->fileName) { $bulkUploadData->fileName = $fileData["name"]; } $dbBulkUploadJobData = $bulkUploadData->toInsertableObject(); $bulkUploadCoreType = kPluginableEnumsManager::apiToCore("BulkUploadType", $bulkUploadData->type); $dbBulkUploadJobData->setBulkUploadObjectType(BulkUploadObjectType::CATEGORY); $dbBulkUploadJobData->setUserId($this->getKuser()->getPuserId()); $dbObjectData = $bulkUploadCategoryData->toInsertableObject(); $dbBulkUploadJobData->setObjectData($dbObjectData); $dbBulkUploadJobData->setFilePath($fileData["tmp_name"]); $dbJob = kJobsManager::addBulkUploadJob($this->getPartner(), $dbBulkUploadJobData, $bulkUploadCoreType); $dbJobLog = BatchJobLogPeer::retrieveByBatchJobId($dbJob->getId()); if (!$dbJobLog) { return null; } $bulkUpload = new KalturaBulkUpload(); $bulkUpload->fromObject($dbJobLog, $this->getResponseProfile()); return $bulkUpload; }
/** * * * @param file $fileData * @param KalturaBulkUploadJobData $bulkUploadData * @param KalturaBulkUploadCategoryData $bulkUploadCategoryData * @return KalturaBulkUpload */ function addFromBulkUpload($fileData, KalturaBulkUploadJobData $bulkUploadData = null, KalturaBulkUploadCategoryData $bulkUploadCategoryData = null) { $kparams = array(); $kfiles = array(); $this->client->addParam($kfiles, "fileData", $fileData); if ($bulkUploadData !== null) { $this->client->addParam($kparams, "bulkUploadData", $bulkUploadData->toParams()); } if ($bulkUploadCategoryData !== null) { $this->client->addParam($kparams, "bulkUploadCategoryData", $bulkUploadCategoryData->toParams()); } $this->client->queueServiceActionCall("category", "addFromBulkUpload", $kparams, $kfiles); if ($this->client->isMultiRequest()) { return $this->client->getMultiRequestResult(); } $resultObject = $this->client->doQueue(); $this->client->throwExceptionIfError($resultObject); $this->client->validateObjectType($resultObject, "KalturaBulkUpload"); return $resultObject; }