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();
    }
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();
    }
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 ( ) ; }
Uploads a local file

@param string $bucket bucket name
@param string $object object name
@param string $file local file path
@param array $options
@return null
@throws OssException
Uploads a local file