ALIOSS::get_object PHP Method

get_object() public method

获得Object内容
Since: 2011-11-14
public get_object ( $bucket, string $object, array $options = null ) : ResponseCore
$object string (Required)
$options array (Optional)
return ResponseCore
    public function get_object($bucket, $object, $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);
        if (isset($options[self::OSS_FILE_DOWNLOAD]) && $this->chk_chinese($options[self::OSS_FILE_DOWNLOAD])) {
            $options[self::OSS_FILE_DOWNLOAD] = iconv('utf-8', 'gbk', $options[self::OSS_FILE_DOWNLOAD]);
        }
        $options[self::OSS_BUCKET] = $bucket;
        $options[self::OSS_METHOD] = 'GET';
        $options[self::OSS_OBJECT] = $object;
        if (isset($options['lastmodified'])) {
            $options[self::OSS_HEADERS][self::OSS_IF_MODIFIED_SINCE] = $options['lastmodified'];
            unset($options['lastmodified']);
        }
        if (isset($options['etag'])) {
            $options[self::OSS_HEADERS][self::OSS_IF_NONE_MATCH] = $options['etag'];
            unset($options['etag']);
        }
        if (isset($options['range'])) {
            $options[self::OSS_HEADERS][self::OSS_RANGE] = 'bytes=' . $options['range'];
            unset($options['range']);
        }
        return $this->auth($options);
    }

Usage Example

Esempio n. 1
0
 function ftp_get($file, $path)
 {
     $obj = new ALIOSS();
     $obj->set_host_name($this->hostname, $this->port);
     $obj->set_debug_mode(FALSE);
     $bucket = $this->bucket;
     $file = jishigou_oss::clear($file);
     $path = jishigou_oss::clear($path);
     $options = array(ALIOSS::OSS_FILE_DOWNLOAD => $path);
     $response = $obj->get_object($bucket, $file, $options);
     $rt = jishigou_oss::status($response);
     return $rt == '2' ? 1 : 0;
 }