Merge branch 'main' of https://git.nianxx.cn/zoujing/YGChatCS into fix-109
This commit is contained in:
32
src/request/api/UpdateFile.js
Normal file
32
src/request/api/UpdateFile.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import { BASE_URL } from "@/request/base/baseUrl";
|
||||
import { getCurrentConfig } from "@/constant/base";
|
||||
|
||||
export const updateImageFile = (file) => {
|
||||
const url = BASE_URL + "/common/upload";
|
||||
const token = uni.getStorageSync("token");
|
||||
const clientId = getCurrentConfig().clientId;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.uploadFile({
|
||||
url,
|
||||
filePath: file,
|
||||
name: "file",
|
||||
header: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
Authorization: `Bearer ${token}`,
|
||||
clientId: clientId,
|
||||
},
|
||||
formData: {
|
||||
file: "file",
|
||||
},
|
||||
success: (uploadFileRes) => {
|
||||
console.log(uploadFileRes.data);
|
||||
resolve(uploadFileRes.data);
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error("上传图片失败:", err);
|
||||
reject(err);
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user