/**
* 上传本地文件
*
* @param string $bucket bucket名称
* @param string $object object名称
* @param string $file 本地文件路径
* @param array $options
* @return null
* @throws OssException
*/
public function uploadFile($bucket, $object, $file, $options = NULL)
{
$this->precheckCommon($bucket, $object, $options);
OssUtil::throwOssExceptionWithMessageIfEmpty($file, "file path is invalid");
$file = OssUtil::encodePath($file);
if (!file_exists($file)) {
throw new OssException($file . " file does not exist");
}
$options[self::OSS_FILE_UPLOAD] = $file;
$file_size = filesize($options[self::OSS_FILE_UPLOAD]);
$is_check_md5 = $this->isCheckMD5($options);
if ($is_check_md5) {
$content_md5 = base64_encode(md5_file($options[self::OSS_FILE_UPLOAD], true));
$options[self::OSS_CONTENT_MD5] = $content_md5;
}
if (!isset($options[self::OSS_CONTENT_TYPE])) {
$options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object, $file);
}
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_OBJECT] = $object;
$options[self::OSS_CONTENT_LENGTH] = $file_size;
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
}
至尊宝的传说
元芳怎么了
泛舟湖上清波郎朗