Skip to content

Commit 25c9f58

Browse files
committed
fix(client-sdk): fix old file upload api;
1 parent b8a22dd commit 25c9f58

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

packages/client-sdk/src/cloud.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,8 @@ class Cloud {
9191
/**
9292
* 调用云函数
9393
*/
94-
async invokeFunction<T = any>(functionName: string, data: any, debug = false): Promise<T> {
95-
let url = this.funcBaseUrl + `/invoke/${functionName}`
96-
if (debug) {
97-
url = url + `?debug=true`
98-
}
94+
async invokeFunction<T = any>(functionName: string, data: any): Promise<T> {
95+
const url = this.funcBaseUrl + `/${functionName}`
9996
const res = await this
10097
._request
10198
.request(url, data)
@@ -105,12 +102,18 @@ class Cloud {
105102

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

0 commit comments

Comments
 (0)