Exemplo n.º 1
0
<?php

require_once '../libs/BaiduPCS.class.php';
//请根据实际情况更新$access_token与$appName参数
$access_token = '3.839af46f54db6ed60797847d2febbca0.2592000.1359262544.754976761-248414';
//应用目录名
$appName = '测试应用';
//应用根目录
$root_dir = '/apps' . '/' . $appName . '/';
$fileName = 'pic_list.jpg';
//文件路径
$path = $root_dir . $fileName;
$pcs = new BaiduPCS($access_token);
header('Content-Disposition:attachment;filename="' . $fileName . '"');
header('Content-Type:application/octet-stream');
$result = $pcs->download($path);
echo $result;
Exemplo n.º 2
0
    header('X-Pad: avoid browser bug');
} elseif (in_array($file_ext, array('asf', 'avi', 'flv', 'mkv', 'mov', 'mp4', 'wmv', '3gp', '3g2', 'mpeg', 'rm', 'rmvb', 'qt'))) {
    $meta = $BaiduPCS->getMeta($path);
    $meta = json_decode($meta, true);
    if (isset($meta['error_msg'])) {
        header("Content-Type: text/html; charset=utf8");
        echo $meta['error_msg'];
        exit;
    }
    $meta = $meta['list'][0];
    $meta = $meta['block_list'];
    $meta = json_decode($meta);
    $meta = $meta[0];
    header("Location: video-player.php?path=" . urlencode($path) . "&md5=" . $meta);
    exit;
} else {
    $result = $BaiduPCS->download($path);
    $meta = json_decode($result, true);
    if (isset($meta['error_msg'])) {
        header("Content-Type: text/html; charset=utf8");
        echo $meta['error_msg'];
        exit;
    }
    header("Content-Type: application/octet-stream");
    header('Content-Disposition:inline;filename="' . $file_name . '"');
    header('Accept-Ranges: bytes');
}
ob_clean();
echo $result;
flush();
exit;