本文整理汇总了PHP中kFile::dumpFile方法的典型用法代码示例。如果您正苦于以下问题:PHP kFile::dumpFile方法的具体用法?PHP kFile::dumpFile怎么用?PHP kFile::dumpFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kFile
的用法示例。
在下文中一共展示了kFile::dumpFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
$ui_conf_id = $this->getRequestParameter("ui_conf_id");
$preloader_path = myContentStorage::getFSContentRootPath() . "/content" . myContentStorage::getFSUiconfRootPath() . "/preloader_{$ui_conf_id}.swf";
if (!file_exists($preloader_path)) {
$preloader_path = myContentStorage::getFSContentRootPath() . "/content" . myContentStorage::getFSUiconfRootPath() . "/preloader_2.swf";
}
kFile::dumpFile($preloader_path);
}
示例2: execute
public function execute()
{
$this->forceSystemAuthentication();
$file_path = $this->getP("file_path");
if (!file_exists($file_path)) {
echo "Cannot find file [{$file_path}]";
die;
}
$mime_type = kFile::mimeType($file_path);
// echo "[[$mime_type]]";
kFile::dumpFile($file_path, $mime_type);
die;
}
示例3: execute
public function execute()
{
requestUtils::handleConditionalGet();
$flavorId = $this->getRequestParameter("flavorId");
$shouldProxy = $this->getRequestParameter("forceproxy", false);
$ks = $this->getRequestParameter("ks");
$fileParam = $this->getRequestParameter("file");
$referrer = base64_decode($this->getRequestParameter("referrer"));
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = '';
}
$flavorAsset = flavorAssetPeer::retrieveById($flavorId);
if (is_null($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$entry = entryPeer::retrieveByPK($flavorAsset->getEntryId());
if (is_null($entry)) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
myPartnerUtils::blockInactivePartner($flavorAsset->getPartnerId());
myPartnerUtils::enforceDelivery($flavorAsset->getPartnerId());
//disabled enforce cdn because of rtmp delivery
//requestUtils::enforceCdnDelivery($flavorAsset->getPartnerId());
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (!kFileSyncUtils::file_exists($syncKey, false)) {
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if (is_null($fileSync)) {
KalturaLog::log("Error - no FileSync for flavor [" . $flavorAsset->getId() . "]");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
// always dump remote urls so they will be cached by the cdn transparently
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
kFile::dumpUrl($remoteUrl, true, true);
}
$path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
$flvWrapper = new myFlvHandler($path);
$isFlv = $flvWrapper->isFlv();
$clipFrom = $this->getRequestParameter("clipFrom", 0);
// milliseconds
$clipTo = $this->getRequestParameter("clipTo", 2147483647);
// milliseconds
if ($clipTo == 0) {
$clipTo = 2147483647;
}
if (is_dir($path) && $fileParam) {
$path .= "/{$fileParam}";
//echo "path($path),file($fileParam)";
kFile::dumpFile($path, null, null);
die;
} else {
if (!$isFlv) {
$limit_file_size = 0;
if ($clipTo != 2147483647) {
$mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($flavorAsset->getId());
if ($mediaInfo && ($mediaInfo->getVideoDuration() || $mediaInfo->getAudioDuration() || $mediaInfo->getContainerDuration())) {
$duration = $mediaInfo->getVideoDuration() ? $mediaInfo->getVideoDuration() : ($mediaInfo->getAudioDuration() ? $mediaInfo->getAudioDuration() : $mediaInfo->getContainerDuration());
$limit_file_size = floor(@filesize($path) * ($clipTo / $duration));
}
}
kFile::dumpFile($path, null, null, $limit_file_size);
die;
}
}
$audioOnly = $this->getRequestParameter("audioOnly");
// milliseconds
if ($audioOnly === '0') {
// audioOnly was explicitly set to 0 - don't attempt to make further automatic investigations
} elseif ($flvWrapper->getFirstVideoTimestamp() < 0) {
$audioOnly = true;
}
$seekFrom = $this->getRequestParameter("seekFrom", -1);
if ($seekFrom <= 0) {
$seekFrom = -1;
}
$seekFromBytes = $this->getRequestParameter("seekFromBytes", -1);
if ($seekFromBytes <= 0) {
$seekFromBytes = -1;
}
$bytes = 0;
if ($seekFrom !== -1 && $seekFrom !== 0) {
list($bytes, $duration, $firstTagByte, $toByte) = $flvWrapper->clip(0, -1, $audioOnly);
list($bytes, $duration, $fromByte, $toByte, $seekFromTimestamp) = $flvWrapper->clip($seekFrom, -1, $audioOnly);
$seekFromBytes = myFlvHandler::FLV_HEADER_SIZE + $flvWrapper->getMetadataSize($audioOnly) + $fromByte - $firstTagByte;
} else {
list($bytes, $duration, $fromByte, $toByte, $fromTs, $cuepointPos) = myFlvStaticHandler::clip($path, $clipFrom, $clipTo, $audioOnly);
}
$metadataSize = $flvWrapper->getMetadataSize($audioOnly);
$dataOffset = $metadataSize + myFlvHandler::getHeaderSize();
$totalLength = $dataOffset + $bytes;
list($bytes, $duration, $fromByte, $toByte, $fromTs, $cuepointPos) = myFlvStaticHandler::clip($path, $clipFrom, $clipTo, $audioOnly);
list($rangeFrom, $rangeTo, $rangeLength) = requestUtils::handleRangeRequest($totalLength);
if ($totalLength < 1000) {
// (actually $total_length is probably 13 or 143 - header + empty metadata tag) probably a bad flv maybe only the header - dont cache
requestUtils::sendCdnHeaders("flv", $rangeLength, 0);
} else {
requestUtils::sendCdnHeaders("flv", $rangeLength);
}
header('Content-Disposition: attachment; filename="video.flv"');
// dont inject cuepoint into the stream
//.........这里部分代码省略.........
示例4: dumpFile
private function dumpFile($file_path, $file_name, $wams_asset_id = null, $wams_url = null)
{
$relocate = $this->getRequestParameter("relocate");
$directServe = $this->getRequestParameter("direct_serve");
if (!$relocate) {
$url = $_SERVER["REQUEST_URI"];
if (strpos($url, "?") !== false) {
$url .= "&relocate=";
} else {
$url .= "/relocate/";
}
$url .= $this->encodeUrl($file_name);
kFile::cacheRedirect($url);
header("Location: {$url}");
die;
} else {
if (!$directServe) {
header("Content-Disposition: attachment; filename=\"{$file_name}\"");
}
if (!empty($wams_asset_id)) {
$fileSync = FileSyncPeer::retrieveByWamsAssetId($wams_asset_id);
kWAMS::getInstance($fileSync->getPartnerId())->dumpFile($wams_asset_id, pathinfo($file_name, PATHINFO_EXTENSION));
} else {
$mime_type = kFile::mimeType($file_path);
kFile::dumpFile($file_path, $mime_type);
}
}
}
示例5: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
// where file is {entryId/flavorId}.{ism,ismc,ismv}
$objectId = $type = null;
$objectIdStr = $this->getRequestParameter("objectId");
list($objectId, $type) = @explode(".", $objectIdStr);
if (!$type || !$objectId) {
die;
}
$ks = $this->getRequestParameter("ks");
$referrer = base64_decode($this->getRequestParameter("referrer"));
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = '';
}
if ($type == "ism" || $type == "ismc") {
// backward compatiblity - to be removed once ismc is created with pure objectId.ext instead of entryId_flavorId_version.ext
if (strlen($objectId) != 10) {
$version = substr($objectId, 13);
$objectId = substr($objectId, 0, 10);
} else {
$version = null;
}
$entry = entryPeer::retrieveByPK($objectId);
if (is_null($entry)) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
$syncKey = $entry->getSyncKey($type == "ism" ? entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM : entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC, $version);
} else {
if ($type == "ismv") {
// backward compatiblity - to be removed once ismc is created with pure objectId.ext instead of entryId_flavorId_version.ext
if (strlen($objectId) != 10) {
$version = substr($objectId, 22);
$objectId = substr($objectId, 11, 10);
} else {
$version = null;
}
$flavorAsset = flavorAssetPeer::retrieveById($objectId);
if (is_null($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$entry = entryPeer::retrieveByPK($flavorAsset->getEntryId());
if (is_null($entry)) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET, $version);
} else {
die;
}
}
if (!kFileSyncUtils::file_exists($syncKey, false)) {
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if (is_null($fileSync)) {
KalturaLog::log("Error - no FileSync for type [{$type}] objectId [{$objectId}]");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
kFile::dumpUrl($remoteUrl);
}
$path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
kFile::dumpFile($path);
}
示例6: execute
public function execute()
{
requestUtils::handleConditionalGet();
$entry_id = $this->getRequestParameter("entry_id");
$ks_str = $this->getRequestParameter("ks");
$base64_referrer = $this->getRequestParameter("referrer");
$referrer = base64_decode($base64_referrer);
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = "";
}
$clip_from = $this->getRequestParameter("clip_from", 0);
// milliseconds
$clip_to = $this->getRequestParameter("clip_to", 2147483647);
// milliseconds
if ($clip_to == 0) {
$clip_to = 2147483647;
}
$request = $_SERVER["REQUEST_URI"];
// remove dynamic fields from the url so we'll request a single url from the cdn
$request = str_replace("/referrer/{$base64_referrer}", "", $request);
$request = str_replace("/ks/{$ks_str}", "", $request);
// workaround the filter which hides all the deleted entries -
// now that deleted entries are part of xmls (they simply point to the 'deleted' templates), we should allow them here
$entry = entryPeer::retrieveByPKNoFilter($entry_id);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
myPartnerUtils::blockInactivePartner($entry->getPartnerId());
// set the memory size to be able to serve big files in a single chunk
ini_set("memory_limit", "64M");
// set the execution time to be able to serve big files in a single chunk
ini_set("max_execution_time", 240);
if ($entry->getType() == entryType::MIX && $entry->getStatus() == entryStatus::DELETED) {
// because the fiter was turned off - a manual check for deleted entries must be done.
die;
} else {
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$version = $this->getRequestParameter("version", null);
$width = $this->getRequestParameter("width", -1);
$height = $this->getRequestParameter("height", -1);
$crop_provider = $this->getRequestParameter("crop_provider", null);
$bgcolor = $this->getRequestParameter("bgcolor", "ffffff");
$type = $this->getRequestParameter("type", 1);
$quality = $this->getRequestParameter("quality", 0);
$src_x = $this->getRequestParameter("src_x", 0);
$src_y = $this->getRequestParameter("src_y", 0);
$src_w = $this->getRequestParameter("src_w", 0);
$src_h = $this->getRequestParameter("src_h", 0);
$vid_sec = $this->getRequestParameter("vid_sec", -1);
$vid_slice = $this->getRequestParameter("vid_slice", -1);
$vid_slices = $this->getRequestParameter("vid_slices", -1);
if ($width == -1 && $height == -1) {
$width = 640;
$height = 480;
} else {
if ($width == -1) {
// if only either width or height is missing reset them to zero, and convertImage will handle them
$width = 0;
} else {
if ($height == -1) {
$height = 0;
}
}
}
$tempThumbPath = myEntryUtils::resizeEntryImage($entry, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices);
kFile::dumpFile($tempThumbPath, null, strpos($tempThumbPath, "_NOCACHE_") === false ? null : 0);
}
}
$audio_only = $this->getRequestParameter("audio_only");
// milliseconds
$flavor = $this->getRequestParameter("flavor", 1);
//
$flavor_param_id = $this->getRequestParameter("flavor_param_id", null);
//
$streamer = $this->getRequestParameter("streamer");
//
if (substr($streamer, 0, 4) == "rtmp") {
// the fms may add .mp4 to the end of the url
$streamer = "rtmp";
}
// grab seek_from_bytes parameter and normalize url
$seek_from_bytes = $this->getRequestParameter("seek_from_bytes", -1);
$request = str_replace("/seek_from_bytes/{$seek_from_bytes}", "", $request);
if ($seek_from_bytes <= 0) {
$seek_from_bytes = -1;
}
// grab seek_from parameter and normalize url
$seek_from = $this->getRequestParameter("seek_from", -1);
$request = str_replace("/seek_from/{$seek_from}", "", $request);
if ($seek_from <= 0) {
$seek_from = -1;
}
$this->dump_from_byte = 0;
// reset accurate seek from timestamp
$seek_from_timestamp = -1;
// backward compatibility
if ($flavor === "0") {
// for edit version
$flavor = "edit";
//.........这里部分代码省略.........
示例7: serveFile
/**
* @param EntryDistribution $entryDistribution
* @param int $fileSubType
* @param string $fileName
* @param bool $forceProxy
* @throws KalturaAPIException
*/
protected function serveFile(EntryDistribution $entryDistribution, $fileSubType, $fileName, $forceProxy = false)
{
$syncKey = $entryDistribution->getSyncKey($fileSubType);
if (!kFileSyncUtils::fileSync_exists($syncKey)) {
throw new KalturaAPIException(ContentDistributionErrors::ENTRY_DISTRIBUTION_MISSING_LOG, $entryDistribution->getId(), $fileSubType);
}
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
if ($local) {
$filePath = $fileSync->getFullPath();
$mimeType = kFile::mimeType($filePath);
kFile::dumpFile($filePath, $mimeType);
} else {
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
KalturaLog::info("Redirecting to [{$remoteUrl}]");
if ($forceProxy) {
kFile::dumpUrl($remoteUrl);
} else {
// or redirect if no proxy
header("Location: {$remoteUrl}");
}
}
}
示例8: serveAction
/**
* serve action returan the file from dataContent field.
*
* @action serve
* @serverOnly
* @param string $entryId Data entry id
* @param int $version Desired version of the data
* @param bool $forceProxy force to get the content without redirect
*
* @throws KalturaErrors::ENTRY_ID_NOT_FOUND
*/
function serveAction($entryId, $version = -1, $forceProxy = false)
{
$dbEntry = entryPeer::retrieveByPK($entryId);
if (!$dbEntry || $dbEntry->getType() != KalturaEntryType::DATA) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$ksObj = $this->getKs();
$ks = $ksObj ? $ksObj->getOriginalString() : null;
$securyEntryHelper = new KSecureEntryHelper($dbEntry, $ks, null);
$securyEntryHelper->validateForDownload();
if (!$version || $version == -1) {
$version = null;
}
$fileName = $dbEntry->getName();
$syncKey = $dbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version);
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
if ($local) {
$filePath = $fileSync->getFullPath();
$mimeType = kFile::mimeType($filePath);
kFile::dumpFile($filePath, $mimeType);
} else {
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
KalturaLog::info("Redirecting to [{$remoteUrl}]");
if ($forceProxy) {
kFile::dumpUrl($remoteUrl);
} else {
// or redirect if no proxy
header("Location: {$remoteUrl}");
}
}
}
示例9: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
requestUtils::handleConditionalGet();
$entry_id = $this->getRequestParameter("entry_id");
$type = $this->getRequestParameter("type");
$ks = $this->getRequestParameter("ks");
$file_sync = null;
$ret_file_name = "name";
$referrer = $this->getRequestParameter("referrer");
$referrer = base64_decode($referrer);
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = "";
}
$request_file_name = $this->getRequestParameter("file_name");
if ($request_file_name) {
$ret_file_name = $request_file_name;
}
$direct_serve = $this->getRequestParameter("direct_serve");
$entry = entryPeer::retrieveByPK($entry_id);
if (!$entry) {
// what to return ??
die;
}
myPartnerUtils::blockInactivePartner($entry->getPartnerId());
$securyEntryHelper = new KSecureEntryHelper($entry, $ks, $referrer);
$securyEntryHelper->validateForDownload();
// Rmoved by Tan-Tan - asked by Eran
// // allow access only via cdn unless these are documents (due to the current implementation of convert ppt2swf)
// if ($entry->getType() != entryType::DOCUMENT && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_IMAGE)
// {
// requestUtils::enforceCdnDelivery($entry->getPartnerId());
// }
// relocate = did we use the redirect and added the extension to the name
$relocate = $this->getRequestParameter("relocate");
if ($ret_file_name == "name") {
$ret_file_name = $entry->getName();
}
if ($ret_file_name) {
//rawurlencode to content-disposition filename to handle spaces and other characters across different browsers
//$name = rawurlencode($ret_file_name);
// 19.04.2009 (Roman) - url encode is not needed when the filename in Content-Disposition header is in quotes
// IE6/FF3/Chrome - Will show the filename correctly
// IE7 - Will show the filename with underscores instead of spaces (this is better than showing %20)
$name = $ret_file_name;
if ($name) {
if ($relocate) {
// if we have a good file extension (from the first time) - use it in the content-disposition
// in some browsers it will be stronger than the URL's extension
$file_ext = pathinfo($relocate, PATHINFO_EXTENSION);
$name .= ".{$file_ext}";
}
if (!$direct_serve) {
header("Content-Disposition: attachment; filename=\"{$name}\"");
}
}
} else {
$ret_file_name = $entry_id;
}
$format = $this->getRequestParameter("format");
if ($type == "download" && $format && $entry->getType() != entryType::DOCUMENT) {
// this is a video for a specifc extension - use the proper flavorAsset
$flavor_asset = flavorAssetPeer::retrieveByEntryIdAndExtension($entry_id, $format);
if ($flavor_asset && $flavor_asset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) {
$file_sync = $this->redirectIfRemote($flavor_asset, flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET, null, true);
} else {
header('KalturaRaw: no flavor asset for extension');
header("HTTP/1.0 404 Not Found");
die;
}
$archive_file = $file_sync->getFullPath();
$mime_type = kFile::mimeType($archive_file);
kFile::dumpFile($archive_file, $mime_type);
}
// TODO - move to a different action - document should be plugin
if ($entry->getType() == entryType::DOCUMENT) {
// use the fileSync from the entry
if ($type == "download" && $format) {
$flavor_asset = flavorAssetPeer::retrieveByEntryIdAndExtension($entry_id, $format);
} else {
$flavor_asset = flavorAssetPeer::retrieveOriginalByEntryId($entry_id);
}
if ($flavor_asset && $flavor_asset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) {
$file_sync = $this->redirectIfRemote($flavor_asset, flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET, null, true);
} else {
header('KalturaRaw: no flavor asset for extension');
header("HTTP/1.0 404 Not Found");
die;
}
// Gonen 2010-08-05 workaround to make sure file name includes correct extension
// make sure a file extension is added to the downloaded file so browser will identify and
// allow opening with default program
// for direct serve we do not want to send content-disposition header
if (!$direct_serve) {
$ext = pathinfo($file_sync->getFullPath(), PATHINFO_EXTENSION);
if ($relocate) {
// remove relocate file extension
//.........这里部分代码省略.........
示例10: serveFileToRemoteDataCenter
public static function serveFileToRemoteDataCenter($file_sync_id, $file_hash, $file_name)
{
KalturaLog::log("File sync id [{$file_sync_id}], file_hash [{$file_hash}], file_name [{$file_name}]");
// TODO - verify security
$current_dc = self::getCurrentDc();
$current_dc_id = $current_dc["id"];
// retrieve the object
$file_sync = FileSyncPeer::retrieveByPk($file_sync_id);
if (!$file_sync) {
$error = "DC[{$current_dc_id}]: Cannot find FileSync with id [{$file_sync_id}]";
KalturaLog::err($error);
throw new Exception($error);
}
if ($file_sync->getDc() != $current_dc_id) {
$error = "DC[{$current_dc_id}]: FileSync with id [{$file_sync_id}] does not belong to this DC";
KalturaLog::err($error);
throw new Exception($error);
}
// resolve if file_sync is link
$file_sync_resolved = $file_sync;
if ($file_sync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_LINK) {
$file_sync_resolved = kFileSyncUtils::resolve($file_sync);
}
// check if file sync path leads to a file or a directory
$resolvedPath = $file_sync_resolved->getFullPath();
$fileSyncIsDir = is_dir($resolvedPath);
if ($fileSyncIsDir && $file_name) {
$resolvedPath .= '/' . $file_name;
}
if (!file_exists($resolvedPath)) {
$file_name_msg = $file_name ? "file name [{$file_name}] " : '';
$error = "DC[{$current_dc_id}]: Path for fileSync id [{$file_sync_id}] " . $file_name_msg . "does not exist";
KalturaLog::err($error);
throw new Exception($error);
}
// validate the hash
$expected_file_hash = md5($current_dc["secret"] . $file_sync_id);
// will be verified on the other side to make sure not some attack or external invalid request
if ($file_hash != $expected_file_hash) {
$error = "DC[{$current_dc_id}]: FileSync with id [{$file_sync_id}] - invalid hash";
KalturaLog::err($error);
throw new Exception($error);
}
if ($fileSyncIsDir && is_dir($resolvedPath)) {
KalturaLog::log("Serving directory content from [" . $resolvedPath . "]");
$contents = kFile::listDir($resolvedPath);
sort($contents, SORT_STRING);
$contents = serialize($contents);
header("file-sync-type: dir");
echo $contents;
die;
} else {
KalturaLog::log("Serving file from [" . $resolvedPath . "]");
kFile::dumpFile($resolvedPath);
}
}
示例11: serveFile
/**
* @param ISyncableFile $syncable
* @param int $fileSubType
* @param string $fileName
* @param bool $forceProxy
* @throws KalturaErrors::FILE_DOESNT_EXIST
*/
protected function serveFile(ISyncableFile $syncable, $fileSubType, $fileName, $entryId = null, $forceProxy = false)
{
/* @var $fileSync FileSync */
$syncKey = $syncable->getSyncKey($fileSubType);
if (!kFileSyncUtils::fileSync_exists($syncKey)) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
}
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
if ($local) {
$filePath = $fileSync->getFullPath();
$wamsAssetId = $fileSync->getWamsAssetId();
if (empty($wamsAssetId)) {
$mimeType = kFile::mimeType($filePath);
kFile::dumpFile($filePath, $mimeType);
} else {
kWAMS::getInstance($fileSync->getPartnerId())->dumpFile($wamsAssetId, pathinfo($filePath, PATHINFO_EXTENSION));
}
} else {
if (in_array($fileSync->getDc(), kDataCenterMgr::getDcIds())) {
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
KalturaLog::info("Redirecting to [{$remoteUrl}]");
if ($forceProxy) {
kFile::dumpApiRequest($remoteUrl);
} else {
//TODO find or build function which redurects the API request with all its parameters without using curl.
// or redirect if no proxy
header("Location: {$remoteUrl}");
die;
}
} else {
$remoteUrl = $fileSync->getExternalUrl($entryId);
header("Location: {$remoteUrl}");
die;
}
}
}
示例12: serveFlavorAsset
/**
* Serves the file content
*
* @action serve
* @param flavorAsset $flavorAsset
* @param string $fileName
* @param bool $forceProxy
* @return file
*
* @throws KalturaErrors::FLAVOR_ASSET_IS_NOT_READY
*/
protected function serveFlavorAsset(flavorAsset $flavorAsset, $fileName, $forceProxy = false)
{
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if (!$fileSync) {
throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_IS_NOT_READY, $flavorAsset->getId());
}
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
if ($local) {
$filePath = $fileSync->getFullPath();
$mimeType = kFile::mimeType($filePath);
kFile::dumpFile($filePath, $mimeType);
} else {
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
KalturaLog::info("Redirecting to [{$remoteUrl}]");
if ($forceProxy) {
kFile::dumpUrl($remoteUrl);
} else {
// or redirect if no proxy
header("Location: {$remoteUrl}");
}
}
}
示例13: serveThumbToFile
/**
* @param FileSync $fileSync
* @param bool $local
* @param string $fileName
* @param bool $forceProxy
*/
protected function serveThumbToFile(FileSync $fileSync, $local, $fileName, $forceProxy = false)
{
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
if ($local) {
$filePath = $fileSync->getFullPath();
$mimeType = kFile::mimeType($filePath);
kFile::dumpFile($filePath, $mimeType);
} else {
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
KalturaLog::info("Redirecting to [{$remoteUrl}]");
if ($forceProxy) {
kFile::dumpUrl($remoteUrl);
} else {
// or redirect if no proxy
header("Location: {$remoteUrl}");
}
}
}
示例14: dumpFile
private function dumpFile($file_path, $file_name)
{
$relocate = $this->getRequestParameter("relocate");
$directServe = $this->getRequestParameter("direct_serve");
if (!$relocate) {
$url = $_SERVER["REQUEST_URI"];
if (strpos($url, "?") !== false) {
$url = substr($url, 0, strpos($url, "?"));
}
$url .= "/relocate/" . $this->encodeUrl($file_name);
header("Location: {$url}");
die;
} else {
if (!$directServe) {
header("Content-Disposition: attachment; filename=\"{$file_name}\"");
}
$mime_type = kFile::mimeType($file_path);
kFile::dumpFile($file_path, $mime_type);
}
}
示例15: isset
<?php
require_once ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "bootstrap.php";
KalturaLog::setContext("CLIENTS");
KalturaLog::debug(__FILE__ . " start");
$requestedName = isset($_GET["name"]) ? $_GET['name'] : null;
if (!$requestedName) {
die("File not found");
}
$generatorOutputPath = KAutoloader::buildPath(KALTURA_ROOT_PATH, "generator", "output");
$generatorConfigPath = KAutoloader::buildPath(KALTURA_ROOT_PATH, "generator", "config.ini");
$config = new Zend_Config_Ini($generatorConfigPath);
foreach ($config as $name => $item) {
if ($name === $requestedName && $item->get("public-download")) {
$fileName = $name . ".tar.gz";
$outputFilePath = KAutoloader::buildPath($generatorOutputPath, $fileName);
$outputFilePath = realpath($outputFilePath);
header("Content-disposition: attachment; filename={$fileName}");
kFile::dumpFile($outputFilePath, "application/gzip");
die;
}
}
die("File not found");
KalturaLog::debug(__FILE__ . " end");