ALIOSS::get_sign_url PHP Method

get_sign_url() public method

获取带签名的url
Since: 2011-12-21
public get_sign_url ( string $bucket, string $object, integer $timeout = 60, array $options = null ) : string
$bucket string (Required)
$object string (Required)
$timeout integer (Optional)
$options array (Optional)
return string
    public function get_sign_url($bucket, $object, $timeout = 60, $options = null)
    {
        //options
        $this->validate_options($options);
        if (!$options) {
            $options = array();
        }
        //bucket
        $this->is_empty($bucket, OSS_BUCKET_IS_NOT_ALLOWED_EMPTY);
        //object
        $this->is_empty($object, OSS_OBJECT_IS_NOT_ALLOWED_EMPTY);
        $options[self::OSS_BUCKET] = $bucket;
        $options[self::OSS_OBJECT] = $object;
        $options[self::OSS_METHOD] = self::OSS_HTTP_GET;
        $options[self::OSS_CONTENT_TYPE] = '';
        $timeout = time() + $timeout;
        $options[self::OSS_PREAUTH] = $timeout;
        $options[self::OSS_DATE] = $timeout;
        return $this->auth($options);
    }

Usage Example

Example #1
0
 function sign_url($file, $host = '')
 {
     $obj = new ALIOSS();
     if ($host != '') {
         $obj->set_vhost($host);
     } else {
         $obj->set_host_name("oss.aliyuncs.com");
     }
     $obj->set_enable_domain_style();
     $obj->set_debug_mode(FALSE);
     $bucket = $this->bucket;
     $file = jishigou_oss::clear($file);
     $timeout = $this->stimeout;
     $response = $obj->get_sign_url($bucket, $file, $timeout);
     return $response;
 }