Skip to content

Commit c4e90d7

Browse files
committed
[fix]bug
1 parent e692367 commit c4e90d7

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/pages/oss/minio/index.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,23 @@ const requestSuccessMethod: UploadProps['requestMethod'] = (file) => {
6969
return new Promise((resolve) => {
7070
(async () => {
7171
try {
72+
const today = new Date();
73+
const year = today.getFullYear();
74+
const month = String(today.getMonth() + 1).padStart(2, '0');
75+
const day = String(today.getDate()).padStart(2, '0');
76+
const filename = `${year}-${month}-${day}/pc-vue3/${file[0].name}`;
77+
7278
const preUpload = await preSigned({
73-
name: file[0].name,
79+
name: filename,
7480
category: 1,
7581
});
76-
const formData = new FormData();
77-
formData.append('file', file[0].raw);
7882
7983
const controller = new AbortController();
8084
const { signal } = controller;
8185
requestControllers.push(controller);
82-
const response = await axios.put(preUpload.uri, formData, {
86+
const response = await axios.put(preUpload.uri, file[0].raw, {
8387
headers: {
84-
'Content-Type': 'multipart/form-data',
88+
'Content-Type': file[0].raw.type,
8589
},
8690
signal,
8791
// onUploadProgress: (progressEvent) => {
@@ -96,7 +100,7 @@ const requestSuccessMethod: UploadProps['requestMethod'] = (file) => {
96100
});
97101
if (response.status === 200) {
98102
const uploaded = await preSigned({
99-
name: file[0].name,
103+
name: filename,
100104
category: 0,
101105
});
102106
resolve({

0 commit comments

Comments
 (0)