本文整理汇总了PHP中OC_Response::setContentLengthHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Response::setContentLengthHeader方法的具体用法?PHP OC_Response::setContentLengthHeader怎么用?PHP OC_Response::setContentLengthHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Response
的用法示例。
在下文中一共展示了OC_Response::setContentLengthHeader方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendHeaders
/**
* @param string $filename
* @param string $name
*/
private static function sendHeaders($filename, $name)
{
OC_Response::setContentDispositionHeader($name, 'attachment');
header('Content-Transfer-Encoding: binary');
OC_Response::disableCaching();
$filesize = \OC\Files\Filesystem::filesize($filename);
header('Content-Type: ' . \OC_Helper::getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename)));
if ($filesize > -1) {
OC_Response::setContentLengthHeader($filesize);
}
}
示例2: sendHeaders
/**
* @param string $filename
* @param string $name
* @param boolean $isAttachment ; enforce download of file
*/
private static function sendHeaders($filename, $name, $isAttachment = true)
{
if ($isAttachment) {
OC_Response::setContentDispositionHeader($name, 'attachment');
}
header('Content-Transfer-Encoding: binary');
OC_Response::disableCaching();
$fileSize = \OC\Files\Filesystem::filesize($filename);
$type = \OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename));
header('Content-Type: ' . $type);
if ($fileSize > -1) {
OC_Response::setContentLengthHeader($fileSize);
}
}
示例3: setContentLengthHeader
/**
* Sets the content length header (with possible workarounds)
* @param string|int|float $length Length to be sent
*/
public static function setContentLengthHeader($length)
{
\OC_Response::setContentLengthHeader($length);
}
示例4: sendHeaders
/**
* @param string $filename
* @param string $name
* @param array $rangeArray ('from'=>int,'to'=>int), ...
*/
private static function sendHeaders($filename, $name, array $rangeArray)
{
OC_Response::setContentDispositionHeader($name, 'attachment');
header('Content-Transfer-Encoding: binary', true);
OC_Response::disableCaching();
$fileSize = \OC\Files\Filesystem::filesize($filename);
$type = \OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename));
if ($fileSize > -1) {
if (!empty($rangeArray)) {
header('HTTP/1.1 206 Partial Content', true);
header('Accept-Ranges: bytes', true);
if (count($rangeArray) > 1) {
$type = 'multipart/byteranges; boundary=' . self::getBoundary();
// no Content-Length header here
} else {
header(sprintf('Content-Range: bytes %d-%d/%d', $rangeArray[0]['from'], $rangeArray[0]['to'], $fileSize), true);
OC_Response::setContentLengthHeader($rangeArray[0]['to'] - $rangeArray[0]['from'] + 1);
}
} else {
OC_Response::setContentLengthHeader($fileSize);
}
}
header('Content-Type: ' . $type, true);
}