update attachment & post
This commit is contained in:
@@ -55,4 +55,22 @@ export const attachmentService = {
|
||||
errorCallback(error)
|
||||
}
|
||||
},
|
||||
download: (id: string) => { // 첨부파일 다운로드 - 삭제 파일 가능
|
||||
axios.get(`${ATTACHMENT_API}/download/${id}`, {
|
||||
responseType: 'blob',
|
||||
})
|
||||
.then(response =>{
|
||||
const downloadFileName = decodeURIComponent(response.headers['content-disposition'].replace('attachment; filename*=UTF-8\'\'', ''))
|
||||
|
||||
const url = window.URL.createObjectURL(new Blob([response.data], { type: response.headers['content-type'] }))
|
||||
let link = document.createElement('a')
|
||||
link.href = url
|
||||
link.setAttribute('download', downloadFileName)
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
|
||||
const element = { link }
|
||||
delete element.link
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ export type UploadPayload = {
|
||||
}
|
||||
|
||||
const UPLOAD_API = '/portal-service/api/v1/attachments'
|
||||
const DOWNLOAD_API = `/server/portal-service/api/v1/download`
|
||||
const DOWNLOAD_API = `/portal-service/api/v1/download`
|
||||
|
||||
let fileHeader = {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
@@ -105,4 +105,22 @@ export const fileService = {
|
||||
},
|
||||
deleteAll: (attachmentCode: string) =>
|
||||
axios.delete(`${UPLOAD_API}/${attachmentCode}/children`),
|
||||
download: (id: string) => { // 첨부파일 다운로드 - 삭제 파일 불가
|
||||
axios.get(`${DOWNLOAD_API}/${id}`, {
|
||||
responseType: 'blob',
|
||||
})
|
||||
.then(response =>{
|
||||
const downloadFileName = decodeURIComponent(response.headers['content-disposition'].replace('attachment; filename*=UTF-8\'\'', ''))
|
||||
|
||||
const url = window.URL.createObjectURL(new Blob([response.data], { type: response.headers['content-type'] }))
|
||||
let link = document.createElement('a')
|
||||
link.href = url
|
||||
link.setAttribute('download', downloadFileName)
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
|
||||
const element = { link }
|
||||
delete element.link
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user