|
@@ -1,5 +1,5 @@
|
|
|
import request from '@/config/axios'
|
|
|
-
|
|
|
+import OSS from 'ali-oss'
|
|
|
// 获取所有字典
|
|
|
export const getDictApi = () => {
|
|
|
return request.get({ url: '/dict/list' })
|
|
@@ -10,6 +10,27 @@ export const getDictOneApi = async () => {
|
|
|
return request.get({ url: '/dict/one' })
|
|
|
}
|
|
|
|
|
|
-export const uploadFile = async (data: any) => {
|
|
|
- return request.post({ url: '/api/sysApk/uploadFile', headersType: 'multipart/form-data', data })
|
|
|
+export const uploadFile = async (file: any) => {
|
|
|
+ const res = (await getParam()) as any
|
|
|
+ const resData = res.data as any
|
|
|
+ console.log(file)
|
|
|
+ if (file.size > 1024 * 1000) {
|
|
|
+ const client = new OSS({
|
|
|
+ region: 'oss-cn-nanjing', // OSS地域节点
|
|
|
+ accessKeyId: resData.keyId, // 访问密钥ID
|
|
|
+ accessKeySecret: resData.keySecret, // 访问密钥Secret
|
|
|
+ bucket: resData.bucketName // 存储空间名称
|
|
|
+ })
|
|
|
+ return client.put(resData.uploadPath + '/' + file.name, file)
|
|
|
+ } else {
|
|
|
+ return request.post({
|
|
|
+ url: '/api/sysApk/uploadFile',
|
|
|
+ headersType: 'multipart/form-data',
|
|
|
+ data: file
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export const getParam = async () => {
|
|
|
+ return request.post({ url: '/api/sysApk/getParam' })
|
|
|
}
|