You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
525 B
22 lines
525 B
|
1 year ago
|
import request from '@/utils/request';
|
||
|
|
import {getToken} from "@/utils/auth";
|
||
|
|
|
||
|
|
|
||
|
|
export function addFile(file, config = {}) {
|
||
|
|
const formData = new FormData();
|
||
|
|
formData.append('file', file);
|
||
|
|
|
||
|
|
// 合并默认配置与传入的配置
|
||
|
|
const defaultConfig = {
|
||
|
|
headers: {'Authorization': 'Bearer ' + getToken()},
|
||
|
|
|
||
|
|
};
|
||
|
|
const finalConfig = {...defaultConfig, ...config};
|
||
|
|
|
||
|
|
return request({
|
||
|
|
url: '/file/addFile',
|
||
|
|
method: 'post',
|
||
|
|
data: formData,
|
||
|
|
...finalConfig
|
||
|
|
});
|
||
|
|
}
|