privateDownloadUrl() public method

public privateDownloadUrl ( $baseUrl, $expires = 3600 )
Ejemplo n.º 1
0
 public function downloadTokenOfFront()
 {
     $addr = Input::get('addr');
     if (!isset($addr)) {
         return Response::json(array('errCode' => 21, 'message' => '请传入图片名字'));
     }
     $accessKey = Config::get('qiniu.qiniu.accessKey');
     $secretKey = Config::get('qiniu.qiniu.secretKey');
     $auth = new Auth($accessKey, $secretKey);
     $baseUrl = Config::get('qiniu.domain') . $addr;
     return Response::json(array('errCode' => 21, 'message' => 'ok', 'downloadtoken' => $auth->privateDownloadUrl($baseUrl)));
 }
Ejemplo n.º 2
0
function qiniu_get_real_download_url($path, $expires = 30)
{
    $auth = new Auth(get_option('qiniu_access_key'), get_option('qiniu_secret_key'));
    return $auth->privateDownloadUrl(get_option('qiniu_host') . trim($path), $expires);
}
Ejemplo n.º 3
0
<?php

require_once 'autoload.php';
use Qiniu\Auth;
$accessKey = 'ntL5AciwhaAa35APXKCSlC4KoUKyN77KNPmbHW0K';
$secretKey = 'x5W3KQikAzHTBYRdezWSMY9XGn0MLR0GQLXRd6X1';
$auth = new Auth($accessKey, $secretKey);
$baseUrl = 'http://7xkofd.com1.z0.glb.clouddn.com/FjvQWf2N6wWTlBmSrAqh4OjhUyRg';
$authUrl = $auth->privateDownloadUrl($baseUrl);
function download_remote_file_with_curl($file_url, $save_to)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_POST, 0);
    curl_setopt($ch, CURLOPT_URL, $file_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $file_content = curl_exec($ch);
    curl_close($ch);
    $downloaded_file = fopen($save_to, 'w');
    fwrite($downloaded_file, $file_content);
    fclose($downloaded_file);
}
download_remote_file_with_curl($authUrl, time() . 'file.docx');
Ejemplo n.º 4
0
 public function actionDownload()
 {
     $accessKey = '6dnAU0jREe7QO0nD1ujr6CizVZ87HGhivNS1W9hR';
     $secretKey = 'RYuzaeIJDvFb8KOa9OSlsmlVs7j9A6oFbzwjh9Z0';
     $auth = new Auth($accessKey, $secretKey);
     $baseUrl = 'http://7xkbeq.com1.z0.glb.clouddn.com/u=2117727038,2641018931&fm=21&gp=0.jpg';
     $authUrl = $auth->privateDownloadUrl($baseUrl);
     echo $authUrl;
 }