/**
* 上传文件,适合比较大的文件
* @param string $bucket (Required)
* @param string $object (Required)
* @param string $file (Required)
* @param array $options (Optional)
* @author
xiaobing.meng@alibaba-inc.com
* @since 2012-02-28
* @return ResponseCore
*/
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 ( '.', $file );
$extension = array_pop ( $extension );
$content_type = MimeTypes::get_mimetype(strtolower($extension));
$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;
}
[font=微软雅黑, 'Microsoft Yahei', 'Hiragino Sans GB', tahoma, arial, 宋体]上面是alioss php sdk upload_file_by_file的一段代码,如果文件路径编码是utf-8,这里会把file重新编码成gbk,然后下面用重新编码后的字符去查看这个文件是否存在,相当于把传入的路径都改变了,这里一定会导致文件不存在的错误,同样的问题在多个sdk接口里面都是存在的,难道其他人没有遇到过这个问题?
[font=微软雅黑, 'Microsoft Yahei', 'Hiragino Sans GB', tahoma, arial, 宋体]
-------------------------
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。