
--- client/resources/api/file.js
+++ client/resources/api/file.js
... | ... | @@ -7,5 +7,5 @@ |
7 | 7 |
|
8 | 8 |
// 파일 다운로드 |
9 | 9 |
export const multiFileDownloadProc = (fileIds) => { |
10 |
- return apiClient.get(`/file/multiFileDownload.json`, { responseType: 'blob', params: { fileIds } }); |
|
10 |
+ return apiClient.post(`/file/multiFileDownload.json`, fileIds, { responseType: 'blob' }); |
|
11 | 11 |
}(파일 끝에 줄바꿈 문자 없음) |
--- client/views/pages/bbsDcry/photo/PicHistoryDetail.vue
+++ client/views/pages/bbsDcry/photo/PicHistoryDetail.vue
... | ... | @@ -206,20 +206,24 @@ |
206 | 206 |
} |
207 | 207 |
|
208 | 208 |
let isMultiple = fileList.length > 1; |
209 |
- let fileIds = isMultiple ? fileList.join(',') : fileList[0]; |
|
209 |
+ let fileIds = isMultiple ? fileList : fileList[0]; |
|
210 | 210 |
const response = isMultiple ? await multiFileDownloadProc(fileIds) : await fileDownloadProc(fileIds); |
211 | 211 |
|
212 |
- // 파일명 조회 |
|
212 |
+ // 파일명 추출 부분 수정 |
|
213 | 213 |
let filename = isMultiple ? 'downloadFile.zip' : 'downloadFile.bin'; |
214 |
- const filenameRegex = /file[Nn]ame[^;=\n]*=((['"]).*?\2|[^;\n]*)/; |
|
215 |
- const matches = filenameRegex.exec(response.headers['content-disposition']); |
|
216 |
- if (matches != null && matches[1]) { |
|
217 |
- filename = matches[1].replace(/['"]/g, ''); |
|
214 |
+ const disposition = response.headers['content-disposition']; |
|
215 |
+ if (disposition && disposition.includes('filename=')) { |
|
216 |
+ const filenameRegex = /filename=["']?([^"';\n]*)["']?/i; |
|
217 |
+ const matches = disposition.match(filenameRegex); |
|
218 |
+ if (matches && matches[1]) { |
|
219 |
+ filename = decodeURIComponent(matches[1]); |
|
220 |
+ } |
|
218 | 221 |
} |
219 | 222 |
|
220 |
- // 파일 다운로드 생성 |
|
221 |
- url = window.URL.createObjectURL(new Blob([response.data])); |
|
222 |
- link = document.createElement('a'); |
|
223 |
+ // 파일 다운로드 처리 |
|
224 |
+ const blob = new Blob([response.data]); |
|
225 |
+ const url = window.URL.createObjectURL(blob); |
|
226 |
+ const link = document.createElement('a'); |
|
223 | 227 |
link.href = url; |
224 | 228 |
link.setAttribute('download', filename); |
225 | 229 |
document.body.appendChild(link); |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?