当前位置: 首页>>代码示例>>PHP>>正文


PHP kFile::moveFile方法代码示例

本文整理汇总了PHP中kFile::moveFile方法的典型用法代码示例。如果您正苦于以下问题:PHP kFile::moveFile方法的具体用法?PHP kFile::moveFile怎么用?PHP kFile::moveFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kFile的用法示例。


在下文中一共展示了kFile::moveFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: appendRecordingAction

 /**
  * Append recorded video to live entry
  * 
  * @action appendRecording
  * @param string $entryId Live entry id
  * @param string $assetId Live asset id
  * @param KalturaMediaServerIndex $mediaServerIndex
  * @param KalturaDataCenterContentResource $resource
  * @param float $duration in seconds
  * @param bool $isLastChunk Is this the last recorded chunk in the current session (i.e. following a stream stop event)
  * @return KalturaLiveEntry The updated live entry
  * 
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  */
 function appendRecordingAction($entryId, $assetId, $mediaServerIndex, KalturaDataCenterContentResource $resource, $duration, $isLastChunk = false)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry || !$dbEntry instanceof LiveEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $dbAsset = assetPeer::retrieveById($assetId);
     if (!$dbAsset || !$dbAsset instanceof liveAsset) {
         throw new KalturaAPIException(KalturaErrors::ASSET_ID_NOT_FOUND, $assetId);
     }
     $lastDuration = $dbEntry->getLengthInMsecs();
     if (!$lastDuration) {
         $lastDuration = 0;
     }
     $liveSegmentDurationInMsec = (int) ($duration * 1000);
     $currentDuration = $lastDuration + $liveSegmentDurationInMsec;
     $maxRecordingDuration = (kConf::get('max_live_recording_duration_hours') + 1) * 60 * 60 * 1000;
     if ($currentDuration > $maxRecordingDuration) {
         KalturaLog::err("Entry [{$entryId}] duration [" . $dbEntry->getLengthInMsecs() . "] and current duration [{$currentDuration}] is more than max allwoed duration [{$maxRecordingDuration}]");
         throw new KalturaAPIException(KalturaErrors::LIVE_STREAM_EXCEEDED_MAX_RECORDED_DURATION, $entryId);
     }
     $kResource = $resource->toObject();
     $filename = $kResource->getLocalFilePath();
     if (!$resource instanceof KalturaServerFileResource) {
         $filename = kConf::get('uploaded_segment_destination') . basename($kResource->getLocalFilePath());
         kFile::moveFile($kResource->getLocalFilePath(), $filename);
         chgrp($filename, kConf::get('content_group'));
         chmod($filename, 0640);
     }
     if ($dbAsset->hasTag(assetParams::TAG_RECORDING_ANCHOR) && $mediaServerIndex == KalturaMediaServerIndex::PRIMARY) {
         KalturaLog::debug("Appending assetId {$assetId} to entryId {$entryId}");
         $dbEntry->setLengthInMsecs($currentDuration);
         // Extract the exact video segment duration from the recorded file
         $mediaInfoParser = new KMediaInfoMediaParser($filename, kConf::get('bin_path_mediainfo'));
         $recordedSegmentDurationInMsec = $mediaInfoParser->getMediaInfo()->videoDuration;
         $currentSegmentVodToLiveDeltaTime = $liveSegmentDurationInMsec - $recordedSegmentDurationInMsec;
         $recordedSegmentsInfo = $dbEntry->getRecordedSegmentsInfo();
         $recordedSegmentsInfo->addSegment($lastDuration, $recordedSegmentDurationInMsec, $currentSegmentVodToLiveDeltaTime);
         $dbEntry->setRecordedSegmentsInfo($recordedSegmentsInfo);
         if ($isLastChunk) {
             // Save last elapsed recording time
             $dbEntry->setLastElapsedRecordingTime($currentDuration);
         }
         $dbEntry->save();
     }
     kJobsManager::addConvertLiveSegmentJob(null, $dbAsset, $mediaServerIndex, $filename, $currentDuration);
     if ($mediaServerIndex == KalturaMediaServerIndex::PRIMARY) {
         if (!$dbEntry->getRecordedEntryId()) {
             $this->createRecordedEntry($dbEntry, $mediaServerIndex);
         }
         $recordedEntry = entryPeer::retrieveByPK($dbEntry->getRecordedEntryId());
         if ($recordedEntry) {
             $this->ingestAsset($recordedEntry, $dbAsset, $filename);
         }
     }
     $entry = KalturaEntryFactory::getInstanceByType($dbEntry->getType());
     $entry->fromObject($dbEntry, $this->getResponseProfile());
     return $entry;
 }
开发者ID:kubrickfr,项目名称:server,代码行数:73,代码来源:KalturaLiveEntryService.php

示例2: crop

 public function crop($quality, $cropType, $width = 0, $height = 0, $cropX = 0, $cropY = 0, $cropWidth = 0, $cropHeight = 0, $scaleWidth = 1, $scaleHeight = 1, $bgcolor = 0xffffff, $density = 0, $forceRotation = null, $strip = false)
 {
     if (is_null($quality)) {
         $quality = 100;
     }
     if (is_null($cropType)) {
         $cropType = 1;
     }
     if (is_null($width)) {
         $width = 0;
     }
     if (is_null($height)) {
         $height = 0;
     }
     if (is_null($cropX)) {
         $cropX = 0;
     }
     if (is_null($cropY)) {
         $cropY = 0;
     }
     if (is_null($cropWidth)) {
         $cropWidth = 0;
     }
     if (is_null($cropHeight)) {
         $cropHeight = 0;
     }
     if (is_null($scaleWidth)) {
         $scaleWidth = 1;
     }
     if (is_null($scaleHeight)) {
         $scaleHeight = 1;
     }
     if (is_null($bgcolor)) {
         $bgcolor = 0;
     }
     $cmd = $this->getCommand($quality, $cropType, $width, $height, $cropX, $cropY, $cropWidth, $cropHeight, $scaleWidth, $scaleHeight, $bgcolor, $density, $forceRotation, $strip);
     if ($cmd) {
         KalturaLog::info("Executing: {$cmd}");
         $returnValue = null;
         $output = system($cmd, $returnValue);
         KalturaLog::debug("Returned value: '{$returnValue}'");
         if ($returnValue) {
             return false;
         }
         // Support animated gifs - KImageMagick generates multiple images with a postfix of '-<frame num>'
         if (!kFile::fileSize($this->targetPath)) {
             $targetFiledir = pathinfo($this->targetPath, PATHINFO_DIRNAME);
             $targetFilename = pathinfo($this->targetPath, PATHINFO_FILENAME);
             $targetFileext = pathinfo($this->targetPath, PATHINFO_EXTENSION);
             $firstFrameTargetFile = "{$targetFiledir}/{$targetFilename}-0.{$targetFileext}";
             if (kFile::fileSize($firstFrameTargetFile)) {
                 kFile::moveFile($firstFrameTargetFile, $this->targetPath);
             }
         }
         return true;
     }
     KalturaLog::info("No conversion required, copying source[{$this->srcPath}] to target[{$this->targetPath}]");
     return copy($this->srcPath, $this->targetPath);
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:59,代码来源:KBaseCropper.php

示例3: moveFile

 /**
  * @param KalturaBatchJob $job
  * @param KalturaConcatJobData $data
  * @param string $localTempFilePath
  * @param string $sharedTempFilePath
  * @return KalturaBatchJob
  */
 protected function moveFile(KalturaBatchJob $job, KalturaConvertLiveSegmentJobData $data, $localTempFilePath, $sharedTempFilePath)
 {
     $this->updateJob($job, "Moving file from [{$localTempFilePath}] to [{$sharedTempFilePath}]", KalturaBatchJobStatus::MOVEFILE);
     kFile::moveFile($localTempFilePath, $sharedTempFilePath, true);
     clearstatcache();
     $fileSize = kFile::fileSize($sharedTempFilePath);
     $this->setFilePermissions($sharedTempFilePath);
     if (!$this->checkFileExists($sharedTempFilePath, $fileSize)) {
         return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::NFS_FILE_DOESNT_EXIST, 'File not moved correctly', KalturaBatchJobStatus::RETRY);
     }
     $data->destFilePath = $sharedTempFilePath;
     return $this->closeJob($job, null, null, 'Succesfully moved file', KalturaBatchJobStatus::FINISHED, $data);
 }
开发者ID:DBezemer,项目名称:server,代码行数:20,代码来源:KAsyncConvertLiveSegment.class.php

示例4: toObject

 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;
 }
开发者ID:DBezemer,项目名称:server,代码行数:15,代码来源:KalturaUploadedFileResource.php

示例5: execute

 public function execute()
 {
     ini_set("memory_limit", "128M");
     ini_set("max_execution_time", "240");
     $this->forceSystemAuthentication();
     $start = microtime(true);
     $data = $this->getP("data");
     $file_path = dirname(__FILE__) . "/../data/viewPartnersData.txt";
     if ($data) {
         $time_str = strftime("-%Y-%d-%m_%H-%M-%S", time());
         kFile::moveFile($file_path, $file_path . $time_str);
         file_put_contents($file_path, $data);
         // sync - OK
     } else {
         $data = file_get_contents($file_path);
     }
     $partner_groups = new partnerGroups($file_path);
     $this->partner_group_list = $partner_groups->partner_group_list;
     $this->data = $data;
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:20,代码来源:viewPartnersEditDataAction.class.php

示例6: moveDataFile

 protected function moveDataFile(KalturaConvertLiveSegmentJobData $data, $localTempAmfFilePath, $sharedTempAmfFilePath)
 {
     KalturaLog::debug('moving file from ' . $localTempAmfFilePath . ' to ' . $sharedTempAmfFilePath);
     kFile::moveFile($localTempAmfFilePath, $sharedTempAmfFilePath, true);
     clearstatcache();
     $fileSize = kFile::fileSize($sharedTempAmfFilePath);
     $this->setFilePermissions($sharedTempAmfFilePath);
     if (!$this->checkFileExists($sharedTempAmfFilePath, $fileSize)) {
         KalturaLog::warning('failed to move file to ' . $sharedTempAmfFilePath);
     } else {
         $data->destDataFilePath = $sharedTempAmfFilePath;
     }
 }
开发者ID:dozernz,项目名称:server,代码行数:13,代码来源:KAsyncConvertLiveSegment.class.php

示例7: resizeEntryImage


//.........这里部分代码省略.........
                 $processing = $cache->get($orig_image_path);
                 if ($processing) {
                     KExternalErrors::dieError(KExternalErrors::PROCESSING_CAPTURE_THUMBNAIL);
                 }
                 $cache->put($orig_image_path, true);
                 $flavorAsset = assetPeer::retrieveHighestBitrateByEntryId($entry->getId(), flavorParams::TAG_THUMBSOURCE);
                 if (is_null($flavorAsset)) {
                     $flavorAsset = assetPeer::retrieveOriginalReadyByEntryId($entry->getId());
                     if ($flavorAsset) {
                         $flavorSyncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
                         list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($flavorSyncKey, false, false);
                         if (!$fileSync) {
                             $flavorAsset = null;
                         }
                     }
                     if (is_null($flavorAsset) || !($flavorAsset->hasTag(flavorParams::TAG_MBR) || $flavorAsset->hasTag(flavorParams::TAG_WEB))) {
                         // try the best playable
                         $flavorAsset = assetPeer::retrieveHighestBitrateByEntryId($entry->getId(), null, flavorParams::TAG_SAVE_SOURCE);
                     }
                     if (is_null($flavorAsset)) {
                         // if no READY ORIGINAL entry is available, try to retrieve a non-READY ORIGINAL entry
                         $flavorAsset = assetPeer::retrieveOriginalByEntryId($entry->getId());
                     }
                 }
                 if (is_null($flavorAsset)) {
                     // if no READY ORIGINAL entry is available, try to retrieve a non-READY ORIGINAL entry
                     $flavorAsset = assetPeer::retrieveOriginalByEntryId($entry->getId());
                 }
                 if (is_null($flavorAsset)) {
                     KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
                 }
                 $flavorSyncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
                 $entry_data_path = kFileSyncUtils::getReadyLocalFilePathForKey($flavorSyncKey);
                 if (!$entry_data_path) {
                     // since this is not really being processed on this server, and will probably cause redirect in thumbnailAction
                     // remove from cache so later requests will still get redirected and will not fail on PROCESSING_CAPTURE_THUMBNAIL
                     $cache->remove($orig_image_path);
                     throw new kFileSyncException('no ready filesync on current DC', kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC);
                 }
                 // close db connections as we won't be requiring the database anymore and capturing a thumbnail may take a long time
                 kFile::closeDbConnections();
                 myFileConverter::autoCaptureFrame($entry_data_path, $capturedThumbPath . "temp_", $calc_vid_sec, -1, -1);
                 $cache->remove($orig_image_path);
             }
         }
         // close db connections as we won't be requiring the database anymore and image manipulation may take a long time
         kFile::closeDbConnections();
         // limit creation of more than XX Imagemagick processes
         if (kConf::hasParam("resize_thumb_max_processes_imagemagick") && trim(exec("ps -e -ocmd|awk '{print \$1}'|grep -c " . kConf::get("bin_path_imagemagick"))) > kConf::get("resize_thumb_max_processes_imagemagick")) {
             KExternalErrors::dieError(KExternalErrors::TOO_MANY_PROCESSES);
         }
         // resizing (and editing)) an image file that failes results in a long server waiting time
         // prevent this waiting time (of future requests) in case the resizeing failes
         $cache = new myCache("thumb-processing-resize", 5 * 60);
         // 5 minutes
         $processing = $cache->get($orig_image_path);
         if ($processing) {
             KExternalErrors::dieError(KExternalErrors::PROCESSING_CAPTURE_THUMBNAIL);
         }
         kFile::fullMkdir($processingThumbPath);
         if ($crop_provider) {
             $convertedImagePath = myFileConverter::convertImageUsingCropProvider($orig_image_path, $processingThumbPath, $width, $height, $type, $crop_provider, $bgcolor, true, $quality, $src_x, $src_y, $src_w, $src_h, $density, $stripProfiles);
         } else {
             if (!file_exists($orig_image_path) || !filesize($orig_image_path)) {
                 KExternalErrors::dieError(KExternalErrors::IMAGE_RESIZE_FAILED);
             }
             $imageSizeArray = getimagesize($orig_image_path);
             if ($thumbParams->getSupportAnimatedThumbnail() && is_array($imageSizeArray) && $imageSizeArray[2] === IMAGETYPE_GIF) {
                 $processingThumbPath = kFile::replaceExt($processingThumbPath, "gif");
                 $finalThumbPath = kFile::replaceExt($finalThumbPath, "gif");
             }
             $convertedImagePath = myFileConverter::convertImage($orig_image_path, $processingThumbPath, $width, $height, $type, $bgcolor, true, $quality, $src_x, $src_y, $src_w, $src_h, $density, $stripProfiles, $thumbParams, $format);
         }
         // die if resize operation failed and add failed resizing to cache
         if ($convertedImagePath === null || !@filesize($convertedImagePath)) {
             $cache->put($orig_image_path, true);
             KExternalErrors::dieError(KExternalErrors::IMAGE_RESIZE_FAILED);
         }
         // if resizing secceded remove from cache of failed resizing
         if ($cache->get($orig_image_path)) {
             $cache->remove($orig_image_path, true);
         }
         if ($multi) {
             list($w, $h, $type, $attr, $srcIm) = myFileConverter::createImageByFile($processingThumbPath);
             if (!$im) {
                 $im = imagecreatetruecolor($w * $vid_slices, $h);
             }
             imagecopy($im, $srcIm, $w * $vid_slice, 0, 0, 0, $w, $h);
             imagedestroy($srcIm);
             ++$vid_slice;
         }
     }
     if ($multi) {
         imagejpeg($im, $processingThumbPath);
         imagedestroy($im);
     }
     kFile::fullMkdir($finalThumbPath);
     kFile::moveFile($processingThumbPath, $finalThumbPath);
     return $finalThumbPath;
 }
开发者ID:DBezemer,项目名称:server,代码行数:101,代码来源:myEntryUtils.class.php

示例8: moveExtraFiles

 private function moveExtraFiles(KalturaConvertJobData &$data, $sharedFile)
 {
     $i = 0;
     foreach ($data->extraDestFileSyncs as $destFileSync) {
         $i++;
         clearstatcache();
         $directorySync = is_dir($destFileSync->fileSyncLocalPath);
         if ($directorySync) {
             $fileSize = KBatchBase::foldersize($destFileSync->fileSyncLocalPath);
         } else {
             $fileSize = kFile::fileSize($destFileSync->fileSyncLocalPath);
         }
         $ext = pathinfo($destFileSync->fileSyncLocalPath, PATHINFO_EXTENSION);
         if ($ext) {
             $newName = $sharedFile . '.' . $ext;
         } else {
             $newName = $sharedFile . '.' . $i;
         }
         kFile::moveFile($destFileSync->fileSyncLocalPath, $newName);
         // directory sizes may differ on different devices
         if (!file_exists($newName) || is_file($newName) && kFile::fileSize($newName) != $fileSize) {
             KalturaLog::err("Error: moving file failed");
             die;
         }
         $destFileSync->fileSyncLocalPath = $this->translateLocalPath2Shared($newName);
         if (self::$taskConfig->params->isRemoteOutput) {
             $destFileSync->fileSyncRemoteUrl = $this->distributedFileManager->getRemoteUrl($destFileSync->fileSyncLocalPath);
         }
     }
 }
开发者ID:kubrickfr,项目名称:server,代码行数:30,代码来源:KAsyncConvert.class.php

示例9: moveFile

 private function moveFile(KalturaBatchJob $job, KalturaConvertJobData $data)
 {
     KalturaLog::debug("moveFile({$job->id}, {$data->destFileSyncLocalPath})");
     $uniqid = uniqid("convert_{$job->entryId}_");
     $sharedFile = "{$this->sharedTempPath}/{$uniqid}";
     clearstatcache();
     $fileSize = filesize($data->destFileSyncLocalPath);
     @rename($data->destFileSyncLocalPath . '.log', "{$sharedFile}.log");
     kFile::moveFile($data->destFileSyncLocalPath, $sharedFile);
     if (!file_exists($sharedFile) || filesize($sharedFile) != $fileSize) {
         KalturaLog::err("Error: moving file failed");
         die;
     }
     @chmod($sharedFile, 0777);
     $data->destFileSyncLocalPath = $this->translateLocalPath2Shared($sharedFile);
     if ($this->taskConfig->params->isRemote) {
         $data->destFileSyncRemoteUrl = $this->distributedFileManager->getRemoteUrl($data->destFileSyncLocalPath);
         $job->status = KalturaBatchJobStatus::ALMOST_DONE;
         $job->message = "File ready for download";
     } elseif ($this->checkFileExists($data->destFileSyncLocalPath, $fileSize)) {
         $job->status = KalturaBatchJobStatus::FINISHED;
         $job->message = "File moved to shared";
     } else {
         $job->status = KalturaBatchJobStatus::RETRY;
         $job->message = "File not moved correctly";
     }
     return $this->closeJob($job, null, null, $job->message, $job->status, $data);
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:28,代码来源:KAsyncConvert.class.php

示例10: operate


//.........这里部分代码省略.........
     }
     if (KBatchBase::$taskConfig->params->InletTmpStorageWindows) {
         $trgPrefixWindows = KBatchBase::$taskConfig->params->InletTmpStorageWindows;
     }
     $url = KBatchBase::$taskConfig->params->InletArmadaUrl;
     $login = KBatchBase::$taskConfig->params->InletArmadaLogin;
     $passw = KBatchBase::$taskConfig->params->InletArmadaPassword;
     if (KBatchBase::$taskConfig->params->InletArmadaPriority) {
         $priority = KBatchBase::$taskConfig->params->InletArmadaPriority;
     } else {
         $priority = 5;
     }
     // ----------------------------------
     $inlet = new InletAPIWrap($url);
     KalturaLog::debug(print_r($inlet, 1));
     $rvObj = new XmlRpcData();
     $rv = $inlet->userLogon($login, $passw, $rvObj);
     if (!$rv) {
         throw new KOperationEngineException("Inlet failure: login, rv(" . print_r($rvObj, true) . ")");
     }
     KalturaLog::debug("userLogon - " . print_r($rvObj, 1));
     $paramsMap = KDLUtils::parseParamStr2Map($operator->extra);
     foreach ($paramsMap as $key => $param) {
         switch ($key) {
             case 'encodingTemplate':
             case 'encodingTemplateId':
                 $encodingTemplateId = $param;
                 break;
             case 'encodingTemplateName':
                 $encodingTemplateId = $this->lookForJobTemplateId($inlet, $param);
                 $encodingTemplateName = $param;
                 break;
             case 'priority':
                 $priority = $param;
                 break;
             case 'cloneAndUpadate':
                 $cloneAndUpadate = $param;
                 break;
             default:
                 break;
         }
     }
     // Adjust linux file path to Inlet Armada Windows path
     if (isset($srcPrefixWindows) && isset($srcPrefixLinux)) {
         $srcPrefixLinux = $this->addLastSlashInFolderPath($srcPrefixLinux, "/");
         $srcPrefixWindows = $this->addLastSlashInFolderPath($srcPrefixWindows, "\\");
         $srcFileWindows = str_replace($srcPrefixLinux, $srcPrefixWindows, $inFilePath);
     } else {
         $srcFileWindows = $inFilePath;
     }
     if (isset($trgPrefixWindows)) {
         $trgPrefixLinux = $this->addLastSlashInFolderPath(KBatchBase::$taskConfig->params->localTempPath, "/");
         $trgPrefixWindows = $this->addLastSlashInFolderPath($trgPrefixWindows, "\\");
         $outFileWindows = str_replace($trgPrefixLinux, $trgPrefixWindows, $this->outFilePath);
     } else {
         $outFileWindows = $this->outFilePath;
     }
     $rv = $inlet->jobAdd($encodingTemplateId, $srcFileWindows, $outFileWindows, $priority, $srcFileWindows, array(), "", $rvObj);
     if (!$rv) {
         throw new KOperationEngineException("Inlet failure: add job, rv(" . print_r($rvObj, 1) . ")");
     }
     KalturaLog::debug("jobAdd - encodingTemplate({$encodingTemplateId}), inFile({$srcFileWindows}), outFile({$outFileWindows}),rv-" . print_r($rvObj, 1));
     $jobId = $rvObj->job_id;
     $attemptCnt = 0;
     while ($jobId) {
         sleep(60);
         $rv = $inlet->jobList(array($jobId), $rvObj);
         if (!$rv) {
             throw new KOperationEngineException("Inlet failure: job list, rv(" . print_r($rvObj, 1) . ")");
         }
         switch ($rvObj->job_list[0]->job_state) {
             case InletArmadaJobStatus::CompletedSuccess:
                 $jobId = null;
                 break;
             case InletArmadaJobStatus::CompletedUnknown:
             case InletArmadaJobStatus::CompletedFailure:
                 throw new KOperationEngineException("Inlet failure: job, rv(" . print_r($rvObj, 1) . ")");
                 break;
         }
         if ($attemptCnt % 10 == 0) {
             KalturaLog::debug("waiting for job completion - " . print_r($rvObj, 1));
         }
         $attemptCnt++;
     }
     //KalturaLog::debug("XXX taskConfig=>".print_r(KBatchBase::$taskConfig,1));
     KalturaLog::debug("Job completed successfully - " . print_r($rvObj, 1));
     if ($trgPrefixWindows) {
         $trgPrefixLinux = $this->addLastSlashInFolderPath(KBatchBase::$taskConfig->params->sharedTempPath, "/");
         $outFileLinux = str_replace($trgPrefixWindows, $trgPrefixLinux, $rvObj->job_list[0]->job_output_file);
         //KalturaLog::debug("XXX str_replace($trgPrefixWindows, ".$trgPrefixLinux.", ".$rvObj->job_list[0]->job_output_file.")==>$outFileLinux");
     } else {
         $outFileLinux = $rvObj->job_list[0]->job_output_file;
     }
     if ($outFileLinux != $this->outFilePath) {
         KalturaLog::debug("copy({$outFileLinux}, " . $this->outFilePath . ")");
         kFile::moveFile($outFileLinux, $this->outFilePath, true);
         //copy($outFileLinux, $this->outFilePath);
     }
     return true;
 }
开发者ID:DBezemer,项目名称:server,代码行数:101,代码来源:KOperationEngineInletArmada.php

示例11: moveFromFile

 public static function moveFromFile($temp_file_path, FileSyncKey $target_key, $strict = true, $copyOnly = false, $cacheOnly = false)
 {
     KalturaLog::log(__METHOD__ . " - move file: [{$temp_file_path}] to key [{$target_key}], ");
     $c = FileSyncPeer::getCriteriaForFileSyncKey($target_key);
     if ($cacheOnly) {
         $c->add(FileSyncPeer::FILE_TYPE, FileSync::FILE_SYNC_FILE_TYPE_CACHE);
     } else {
         $c->add(FileSyncPeer::FILE_TYPE, array(FileSync::FILE_SYNC_FILE_TYPE_FILE, FileSync::FILE_SYNC_FILE_TYPE_LINK), Criteria::IN);
     }
     $existsFileSync = FileSyncPeer::doSelectOne($c);
     if ($existsFileSync) {
         KalturaLog::log(__METHOD__ . " - file already exists");
         if ($strict) {
             throw new Exception("key [" . $target_key . "] already exists");
         }
     }
     $targetFullPath = self::getLocalFilePathForKey($target_key);
     if (!$targetFullPath) {
         $targetFullPath = kPathManager::getFilePath($target_key);
         KalturaLog::log(__METHOD__ . " - Generated new path [{$targetFullPath}]");
     }
     if (!file_exists(dirname($targetFullPath))) {
         KalturaLog::log(__METHOD__ . " - creating directory for file");
         kFile::fullMkdir($targetFullPath);
     }
     if (file_exists($temp_file_path)) {
         KalturaLog::log(__METHOD__ . " - {$temp_file_path} file exists");
     } else {
         KalturaLog::log(__METHOD__ . " - {$temp_file_path} file doesnt exist");
     }
     $wamsSupportedFormats = kWAMS::getSupportedFormats();
     $fileExtension = pathinfo($temp_file_path, PATHINFO_EXTENSION);
     if (in_array($fileExtension, $wamsSupportedFormats)) {
         $assetName = self::getWamsAssetNameForKey($target_key);
         if (empty($assetName)) {
             $assetName = pathinfo($temp_file_path, PATHINFO_BASENAME);
         }
         $wamsAssetId = kWAMS::getInstance($target_key->getPartnerId())->publishFileToWAMS($assetName, $temp_file_path);
         if (!empty($wamsAssetId)) {
             if (self::checkDeletedEntry($target_key, $wamsAssetId, $temp_file_path)) {
                 return;
             }
             self::addFromWAMS($wamsAssetId, $target_key, $strict, $cacheOnly);
             if (!self::isAttachment($target_key)) {
                 $wamsTempFilePath = kWAMS::getTempFilePathForAssetId($wamsAssetId, pathinfo($targetFullPath, PATHINFO_EXTENSION));
                 rename($temp_file_path, $wamsTempFilePath);
             } else {
                 unlink($temp_file_path);
             }
             return;
         } else {
             KalturaLog::err("File [{$temp_file_path}] not published to WAMS");
         }
     }
     if ($copyOnly) {
         $success = copy($temp_file_path, $targetFullPath);
     } else {
         $success = kFile::moveFile($temp_file_path, $targetFullPath);
     }
     if ($success) {
         if (!$existsFileSync) {
             self::createSyncFileForKey($target_key, $strict, false, $cacheOnly);
         }
     } else {
         KalturaLog::log(__METHOD__ . " - could not move file from [{$temp_file_path}] to [{$targetFullPath}]");
         throw new Exception("Could not move file from [{$temp_file_path}] to [{$targetFullPath}]");
     }
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:68,代码来源:kFileSyncUtils.class.php

示例12: handleLiveReportExportFinished

 public static function handleLiveReportExportFinished(BatchJob $dbBatchJob, kLiveReportExportJobData $data)
 {
     // Move file from shared temp to it's final location
     $fileName = basename($data->outputPath);
     $directory = myContentStorage::getFSContentRootPath() . "/content/reports/live/" . $dbBatchJob->getPartnerId();
     $filePath = $directory . DIRECTORY_SEPARATOR . $fileName;
     $moveFile = kFile::moveFile($data->outputPath, $filePath);
     if (!$moveFile) {
         KalturaLog::err("Failed to move report file from: " . $data->outputPath . " to: " . $filePath);
         return kFlowHelper::handleLiveReportExportFailed($dbBatchJob, $data);
     }
     $data->outputPath = $filePath;
     $dbBatchJob->setData($data);
     $dbBatchJob->save();
     $expiry = kConf::get("live_report_export_expiry", 'local', self::LIVE_REPORT_EXPIRY_TIME);
     // Create download URL
     $url = self::createLiveReportExportDownloadUrl($dbBatchJob->getPartnerId(), $fileName, $expiry, $data->applicationUrlTemplate);
     if (!$url) {
         KalturaLog::err("Failed to create download URL");
         return kFlowHelper::handleLiveReportExportFailed($dbBatchJob, $data);
     }
     // Create email params
     $time = date("m-d-y H:i", $data->timeReference + $data->timeZoneOffset);
     $email_id = MailType::MAIL_TYPE_LIVE_REPORT_EXPORT_SUCCESS;
     $validUntil = date("m-d-y H:i", $data->timeReference + $expiry + $data->timeZoneOffset);
     $expiryInDays = $expiry / 60 / 60 / 24;
     $params = array($dbBatchJob->getPartner()->getName(), $time, $dbBatchJob->getId(), $url, $expiryInDays, $validUntil);
     $titleParams = array($time);
     // Email it all
     kJobsManager::addMailJob(null, 0, $dbBatchJob->getPartnerId(), $email_id, kMailJobData::MAIL_PRIORITY_NORMAL, kConf::get("live_report_sender_email"), kConf::get("live_report_sender_name"), $data->recipientEmail, $params, $titleParams);
     return $dbBatchJob;
 }
开发者ID:GElkayam,项目名称:server,代码行数:32,代码来源:kFlowHelper.php

示例13: appendRecordingAction

 /**
  * Append recorded video to live entry
  *
  * @action appendRecording
  * @param string $entryId Live entry id
  * @param string $assetId Live asset id
  * @param KalturaMediaServerIndex $mediaServerIndex
  * @param KalturaDataCenterContentResource $resource
  * @param float $duration in seconds
  * @param bool $isLastChunk Is this the last recorded chunk in the current session (i.e. following a stream stop event)
  * @return KalturaLiveEntry The updated live entry
  *
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  */
 function appendRecordingAction($entryId, $assetId, $mediaServerIndex, KalturaDataCenterContentResource $resource, $duration, $isLastChunk = false)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry || !$dbEntry instanceof LiveEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $dbAsset = assetPeer::retrieveById($assetId);
     if (!$dbAsset || !$dbAsset instanceof liveAsset) {
         throw new KalturaAPIException(KalturaErrors::ASSET_ID_NOT_FOUND, $assetId);
     }
     $lastDuration = 0;
     $recordedEntry = null;
     if ($dbEntry->getRecordedEntryId()) {
         $recordedEntry = entryPeer::retrieveByPK($dbEntry->getRecordedEntryId());
         if ($recordedEntry) {
             if ($recordedEntry->getReachedMaxRecordingDuration()) {
                 KalturaLog::err("Entry [{$entryId}] has already reached its maximal recording duration.");
                 throw new KalturaAPIException(KalturaErrors::LIVE_STREAM_EXCEEDED_MAX_RECORDED_DURATION, $entryId);
             }
             // if entry is in replacement, the replacement duration is more accurate
             if ($recordedEntry->getReplacedEntryId()) {
                 $replacementRecordedEntry = entryPeer::retrieveByPK($recordedEntry->getReplacedEntryId());
                 if ($replacementRecordedEntry) {
                     $lastDuration = $replacementRecordedEntry->getLengthInMsecs();
                 }
             } else {
                 $lastDuration = $recordedEntry->getLengthInMsecs();
             }
         }
     }
     $liveSegmentDurationInMsec = (int) ($duration * 1000);
     $currentDuration = $lastDuration + $liveSegmentDurationInMsec;
     $maxRecordingDuration = (kConf::get('max_live_recording_duration_hours') + 1) * 60 * 60 * 1000;
     if ($currentDuration > $maxRecordingDuration) {
         if ($recordedEntry) {
             $recordedEntry->setReachedMaxRecordingDuration(true);
             $recordedEntry->save();
         }
         KalturaLog::err("Entry [{$entryId}] duration [" . $lastDuration . "] and current duration [{$currentDuration}] is more than max allwoed duration [{$maxRecordingDuration}]");
         throw new KalturaAPIException(KalturaErrors::LIVE_STREAM_EXCEEDED_MAX_RECORDED_DURATION, $entryId);
     }
     $kResource = $resource->toObject();
     $filename = $kResource->getLocalFilePath();
     if (!$resource instanceof KalturaServerFileResource) {
         $filename = kConf::get('uploaded_segment_destination') . basename($kResource->getLocalFilePath());
         kFile::moveFile($kResource->getLocalFilePath(), $filename);
         chgrp($filename, kConf::get('content_group'));
         chmod($filename, 0640);
     }
     if ($dbAsset->hasTag(assetParams::TAG_RECORDING_ANCHOR) && $mediaServerIndex == KalturaMediaServerIndex::PRIMARY) {
         $dbEntry->setLengthInMsecs($currentDuration);
         if ($isLastChunk) {
             // Save last elapsed recording time
             $dbEntry->setLastElapsedRecordingTime($currentDuration);
         }
         $dbEntry->save();
     }
     kJobsManager::addConvertLiveSegmentJob(null, $dbAsset, $mediaServerIndex, $filename, $currentDuration);
     if ($mediaServerIndex == KalturaMediaServerIndex::PRIMARY) {
         if (!$dbEntry->getRecordedEntryId()) {
             $this->createRecordedEntry($dbEntry, $mediaServerIndex);
         }
         $recordedEntry = entryPeer::retrieveByPK($dbEntry->getRecordedEntryId());
         if ($recordedEntry) {
             $this->ingestAsset($recordedEntry, $dbAsset, $filename);
         }
     }
     $entry = KalturaEntryFactory::getInstanceByType($dbEntry->getType());
     $entry->fromObject($dbEntry, $this->getResponseProfile());
     return $entry;
 }
开发者ID:dozernz,项目名称:server,代码行数:85,代码来源:KalturaLiveEntryService.php

示例14: operate

 public function operate(kOperator $operator = null, $inFilePath, $configFilePath = null)
 {
     /*
      * Creating unique output folder for nbrPlay/Webex sessions.
      * This is required in order to support concurrent conversion sessions,
      * because the nbrPlay tool generates temp files with the same name.
      * Upon completion move the generated file into the 'regular' outFilePath
      */
     $saveOutPath = $this->outFilePath;
     $path_parts = pathinfo($this->outFilePath);
     $outDir = realpath($path_parts['dirname']);
     /*
      * The temp folder name
      */
     $tempFolder = "{$outDir}/" . $path_parts['basename'] . ".webex_temp_folder";
     $tempOutPath = "{$tempFolder}/" . $path_parts['basename'];
     if (!file_exists($tempFolder)) {
         $oldUmask = umask(00);
         $result = @mkdir($tempFolder, 0777, true);
         umask($oldUmask);
     }
     /*
      * Switch to temp forlder
      */
     $this->outFilePath = $tempOutPath;
     $rv = parent::operate($operator, $inFilePath, $configFilePath);
     /*
      * Restore the original
      */
     if (file_exists($tempOutPath)) {
         $outFilelist = kFile::dirList($tempFolder);
         if (isset($outFilelist) && count($outFilelist) > 0) {
             foreach ($outFilelist as $fileName) {
                 for ($tries = 0; $tries < 5; $tries++) {
                     $toFile = "{$outDir}/" . pathinfo($fileName, PATHINFO_BASENAME);
                     $rv = kFile::moveFile($fileName, $toFile);
                     if (!file_exists($fileName)) {
                         break;
                     }
                     KalturaLog::err("Failed to move ({$fileName}) to ({$toFile})");
                     Sleep(60);
                 }
             }
             Sleep(60);
             rmdir($tempFolder);
         }
     }
     $this->outFilePath = $saveOutPath;
     return $rv;
 }
开发者ID:DBezemer,项目名称:server,代码行数:50,代码来源:KOperationEngineWebexNbrplayer.php

示例15: moveFromFile

 public static function moveFromFile($temp_file_path, FileSyncKey $target_key, $strict = true, $copyOnly = false)
 {
     KalturaLog::log(__METHOD__ . " - move file: [{$temp_file_path}] to key [{$target_key}], ");
     $c = FileSyncPeer::getCriteriaForFileSyncKey($target_key);
     $existsFileSync = FileSyncPeer::doSelectOne($c);
     if ($existsFileSync) {
         KalturaLog::log(__METHOD__ . " - file already exists");
         if ($strict) {
             throw new Exception("key [" . $target_key . "] already exists");
         }
     }
     $targetFullPath = self::getLocalFilePathForKey($target_key);
     if (!$targetFullPath) {
         $targetFullPath = kPathManager::getFilePath($target_key);
         KalturaLog::log(__METHOD__ . " - Generated new path [{$targetFullPath}]");
     }
     if (!file_exists(dirname($targetFullPath))) {
         KalturaLog::log(__METHOD__ . " - creating directory for file");
         kFile::fullMkdir($targetFullPath);
     }
     if (file_exists($temp_file_path)) {
         KalturaLog::log(__METHOD__ . " - {$temp_file_path} file exists");
     } else {
         KalturaLog::log(__METHOD__ . " - {$temp_file_path} file doesnt exist");
     }
     if ($copyOnly) {
         $success = copy($temp_file_path, $targetFullPath);
     } else {
         $success = kFile::moveFile($temp_file_path, $targetFullPath);
     }
     if ($success) {
         if (!$existsFileSync) {
             self::createSyncFileForKey($target_key, $strict);
         }
     } else {
         KalturaLog::log(__METHOD__ . " - could not move file from [{$temp_file_path}] to [{$targetFullPath}]");
         throw new Exception("Could not move file from [{$temp_file_path}] to [{$targetFullPath}]");
     }
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:39,代码来源:kFileSyncUtils.class.php


注:本文中的kFile::moveFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。