Skip to content

Commit

Permalink
fix(client-sdk): fix old file upload api;
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Nov 15, 2021
1 parent b8a22dd commit 25c9f58
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/client-sdk/src/cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,8 @@ class Cloud {
/**
* 调用云函数
*/
async invokeFunction<T = any>(functionName: string, data: any, debug = false): Promise<T> {
let url = this.funcBaseUrl + `/invoke/${functionName}`
if (debug) {
url = url + `?debug=true`
}
async invokeFunction<T = any>(functionName: string, data: any): Promise<T> {
const url = this.funcBaseUrl + `/${functionName}`
const res = await this
._request
.request(url, data)
Expand All @@ -105,12 +102,18 @@ class Cloud {

/**
* 上传文件
* @deprecated 此函数已弃用,请通过文件上传地址,自行实现上传
* @param file 文件对象(File)
* @param bucket Bucket 名字
* @param auto_naming 文件名是否由服务端自动生成,默认为 1(自动生成),0(保留原文件名)
* @returns
*/
async uploadFile(file: UploadFile, bucket = 'public') {
async uploadFile(file: UploadFile, bucket: string, auto_naming = 1) {
const auto = auto_naming ? 1 : 0
const res = await this
._request
.upload({
url: this.fileBaseUrl + `/upload/${bucket}`,
url: this.fileBaseUrl + `/${bucket}?auto=${auto}`,
files: [file]
})

Expand Down

0 comments on commit 25c9f58

Please sign in to comment.