public function toObject($object_to_fill = null, $props_to_skip = array()) { if (!$object_to_fill) { $object_to_fill = new kLocalFileResource(); } file_put_contents($fname = tempnam(myContentStorage::getFSUploadsPath(), "KFR"), $this->content); $object_to_fill->setLocalFilePath($fname); $object_to_fill->setSourceType(entry::ENTRY_MEDIA_SOURCE_TEXT); return parent::toObject($object_to_fill, $props_to_skip); }
public function toObject($object_to_fill = null, $props_to_skip = array()) { if (!$object_to_fill) { $object_to_fill = new kLocalFileResource(); } $object_to_fill->setKeepOriginalFile(true); $ret = parent::toObject($object_to_fill, $props_to_skip); /* @var $ret kLocalFileResource */ if (!file_exists($ret->getLocalFilePath())) { throw new KalturaAPIException(KalturaErrors::LOCAL_FILE_NOT_FOUND, $ret->getLocalFilePath()); } return $ret; }
public function toObject($object_to_fill = null, $props_to_skip = array()) { if (!$object_to_fill) { $object_to_fill = new kLocalFileResource(); } $ext = pathinfo($this->fileData['name'], PATHINFO_EXTENSION); $uploadPath = $this->fileData['tmp_name']; $tempPath = myContentStorage::getFSUploadsPath() . '/' . uniqid(time()) . '.' . $ext; $moved = kFile::moveFile($uploadPath, $tempPath, true); if (!$moved) { throw new KalturaAPIException(KalturaErrors::UPLOAD_ERROR); } $object_to_fill->setLocalFilePath($tempPath); return $object_to_fill; }
public function toObject($object_to_fill = null, $props_to_skip = array()) { $this->validateForUsage($object_to_fill, $props_to_skip); if (!$object_to_fill) { $object_to_fill = new kLocalFileResource(); } $content = myContentStorage::getFSContentRootPath(); $entryFullPaths = array('flv' => "{$content}/content/webcam/{$this->token}.flv", 'f4v' => "{$content}/content/webcam/{$this->token}.f4v", 'mp4' => "{$content}/content/webcam/{$this->token}.f4v.mp4"); foreach ($entryFullPaths as $type => $entryFullPath) { if (file_exists($entryFullPath)) { if ($type == 'flv') { $entryFixedFullPath = $entryFullPath . '.fixed.flv'; KalturaLog::debug("Fix webcam full path from [{$entryFullPath}] to [{$entryFixedFullPath}]"); myFlvStaticHandler::fixRed5WebcamFlv($entryFullPath, $entryFixedFullPath); $entryNewFullPath = $entryFullPath . '.clipped.flv'; KalturaLog::debug("Clip webcam full path from [{$entryFixedFullPath}] to [{$entryNewFullPath}]"); myFlvStaticHandler::clipToNewFile($entryFixedFullPath, $entryNewFullPath, 0, 0); $entryFullPath = $entryNewFullPath; if (!file_exists($entryFullPath)) { throw new KalturaAPIException(KalturaErrors::RECORDED_WEBCAM_FILE_NOT_FOUND); } } $object_to_fill->setSourceType(KalturaSourceType::WEBCAM); $object_to_fill->setLocalFilePath($entryFullPath); return $object_to_fill; } } throw new KalturaAPIException(KalturaErrors::RECORDED_WEBCAM_FILE_NOT_FOUND); }
/** * @param AttachmentAsset $attachmentAsset * @param kLocalFileResource $contentResource */ protected function attachLocalFileResource(AttachmentAsset $attachmentAsset, kLocalFileResource $contentResource) { if ($contentResource->getIsReady()) { return $this->attachFile($attachmentAsset, $contentResource->getLocalFilePath(), $contentResource->getKeepOriginalFile()); } $attachmentAsset->setStatus(asset::ASSET_STATUS_IMPORTING); $attachmentAsset->save(); $contentResource->attachCreatedObject($attachmentAsset); }
/** * @param kLocalFileResource $resource * @param entry $dbEntry * @param asset $dbAsset * @return asset */ protected function attachLocalFileResource(kLocalFileResource $resource, entry $dbEntry, asset $dbAsset = null) { $dbEntry->setSource($resource->getSourceType()); $dbEntry->save(); if ($resource->getIsReady()) { return $this->attachFile($resource->getLocalFilePath(), $dbEntry, $dbAsset, $resource->getKeepOriginalFile()); } $lowerStatuses = array(entryStatus::ERROR_CONVERTING, entryStatus::ERROR_IMPORTING, entryStatus::PENDING, entryStatus::NO_CONTENT); if (in_array($dbEntry->getStatus(), $lowerStatuses)) { $dbEntry->setStatus(entryStatus::IMPORT); $dbEntry->save(); } // TODO - move image handling to media service if ($dbEntry->getMediaType() == KalturaMediaType::IMAGE) { $resource->attachCreatedObject($dbEntry); return null; } $isNewAsset = false; if (!$dbAsset) { $isNewAsset = true; $dbAsset = kFlowHelper::createOriginalFlavorAsset($this->getPartnerId(), $dbEntry->getId()); } if (!$dbAsset) { if ($dbEntry->getStatus() == entryStatus::NO_CONTENT) { $dbEntry->setStatus(entryStatus::ERROR_CONVERTING); $dbEntry->save(); } return null; } $dbAsset->setStatus(asset::FLAVOR_ASSET_STATUS_IMPORTING); $dbAsset->save(); $resource->attachCreatedObject($dbAsset); return $dbAsset; }
/** * @param flavorAsset $flavorAsset * @param kLocalFileResource $contentResource */ protected function attachLocalFileResource(flavorAsset $flavorAsset, kLocalFileResource $contentResource) { if ($contentResource->getIsReady()) { return $this->attachFile($flavorAsset, $contentResource->getLocalFilePath(), $contentResource->getKeepOriginalFile()); } // I'm not sure about it... // // $lowerStatuses = array( // entryStatus::ERROR_CONVERTING, // entryStatus::ERROR_IMPORTING, // entryStatus::PENDING, // entryStatus::NO_CONTENT, // ); // // $entry = $flavorAsset->getentry(); // if(in_array($entry->getStatus(), $lowerStatuses)) // { // $entry->setStatus(entryStatus::IMPORT); // $entry->save(); // } $flavorAsset->setStatus(asset::FLAVOR_ASSET_STATUS_IMPORTING); $flavorAsset->save(); $contentResource->attachCreatedObject($flavorAsset); }
/** * @param FileAsset $dbFileAsset * @param kLocalFileResource $contentResource */ protected function attachLocalFileResource(FileAsset $dbFileAsset, kLocalFileResource $contentResource) { if ($contentResource->getIsReady()) { return $this->attachFile($dbFileAsset, $contentResource->getLocalFilePath(), $contentResource->getKeepOriginalFile()); } $dbFileAsset->setStatus(FileAssetStatus::UPLOADING); $dbFileAsset->save(); $contentResource->attachCreatedObject($dbFileAsset); }