# uploadFile

将本地资源上传至云存储空间，如果上传至同一路径则是覆盖。

**请求参数**

| 字段 | 说明 | 数据类型 | 默认值 | 必填 |
| --  | -- | -- | -- | --
| cloudPath   | 云存储路径，命名限制见[文件名命名限制](/minigame/dev/wxcloud/guide/storage/naming)          | String | - | Y |
| fileContent   | 要上传文件的内容  | [Buffer](https://nodejs.org/api/buffer.html) 或 [fs.ReadStream](https://nodejs.org/api/fs.html#fs_class_fs_readstream) | - | Y |

**Promise 返回结果说明**

| 字段 | 说明 | 数据类型 |
| --  | --   | --     |
| fileID | 文件 ID | String |
| statusCode | 服务器返回的 HTTP 状态码 | Number |

**错误返回参数**

| 字段 | 说明 | 数据类型 |
| --  | --   | --     |
| errCode | 错误码 | Number |
| errMsg | 错误信息，格式 apiName:fail msg | String |

### 使用示例

Promise 风格
```js
const cloud = require('wx-server-sdk')
const fs = require('fs')
const path = require('path')

cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})

exports.main = async (event, context) => {
  const fileStream = fs.createReadStream(path.join(__dirname, 'demo.jpg'))
  return await cloud.uploadFile({
    cloudPath: 'demo.jpg',
    fileContent: fileStream,
  })
}
```
