public function upload_file_by_file($bucket, $object, $file, $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);
//file
$this->is_empty($file, OSS_FILE_PATH_IS_NOT_ALLOWED_EMPTY);
if ($this->chk_chinese($file)) {
$file = iconv('utf-8', 'gbk', $file);
}
$options[self::OSS_FILE_UPLOAD] = $file;
if (!file_exists($options[self::OSS_FILE_UPLOAD])) {
throw new OSS_Exception($options[self::OSS_FILE_UPLOAD] . OSS_FILE_NOT_EXIST);
}
$filesize = filesize($options[self::OSS_FILE_UPLOAD]);
$partsize = 1024 * 1024;
//默认为 1M
$extension = explode('.', $object);
$ext = array_pop($extension);
$content_type = MimeTypes::get_mimetype(strtolower($ext));
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_OBJECT] = $object;
$options[self::OSS_CONTENT_TYPE] = $content_type;
$options[self::OSS_CONTENT_LENGTH] = $filesize;
$response = $this->auth($options);
return $response;
}