blog

파일 다운로드

문제 설명\n\n다운로드 방법\nform\n/**\n * 양식 양식 제출 게시물\n * @param {*} url\n * @param {*}\n * @param {*} p...

Oct 8, 2025 · 2 min. read
シェア

문제 설명

모달리티 다운로드

form 폼 메서드

/**
 * Form양식 제출 게시물
 * @param {*} url
 * @param {*} paramsName
 * @param {*} param
 */
export const FormForPost = (url, paramsName, param) => {
 // 양식을 만들고 양식 제출 방법 설정하기
 const form = document.createElement('form')
 form.action = url
 form.method = 'post'
 form.style.display = 'none'
 const input = document.createElement('input')
 input.name = paramsName
 input.value = JSON.stringify(param)
 form.appendChild(input)
 const button = document.createElement('input')
 button.type = 'button'
 form.appendChild(button)
 document.body.appendChild(form)
 form.submit()
 document.body.removeChild(form)
}
/**
 * Form양식 제출 받기
 * @param {*} url
 */
export const FormForGet = url => {
 // 양식 생성 및 양식 제출 방법 설정하기
 const form = document.createElement('form')
 form.action = url
 form.method = 'get'
 form.style.display = 'none'
 const button = document.createElement('input')
 button.type = 'button'
 form.appendChild(button)
 document.body.appendChild(form)
 form.submit()
 document.body.removeChild(form)
}

blob

export const downloadUpdate = async (url, paramsName, data) => { try { const response = await post2(url, { name: paramsName, data, responseType: 'blob' // headers: { // 'content-type': 'application/octet-stream;charset=UTF-8' // } }) // window.console.log('download: ', response) // { type: 'application/octet-stream;charset=UTF-8' } return new Blob([response.data]) } catch (error) { console.error('Error:', error) throw error // 선택적으로 추가 처리를 위해 예외를 던집니다. } } async processExportListOfLiuZhou(data) { const url = this.$store.getters._URL const fileContent = await downloadUpdate( `${url}/sample/process/file/download`, 'request', data ) const blobUrl = window.URL.createObjectURL(fileContent) const link = document.createElement('a') link.href = blobUrl link.setAttribute('download', data.fileName) document.body.appendChild(link) link.style.display = 'none' link.click() document.body.removeChild(link) window.URL.revokeObjectURL(url) }

file-saver

import { saveAs } from 'file-saver' const url = this.$store.getters._URL const fileContent = await downloadUpdate( `${url}/sample/process/file/download`, 'request', data ) saveAs(fileContent, data.fileName)
Read next

리눅스에서 아파치 HTTP 서버 구성하기

리눅스 세계에서 모든 종류의 "신비한" 결함을 해결하는 것보다 더 골치 아픈 것이 있다면 그것은 바로 아파치 HTTP 서버의 구성일 것입니다. 아파치에 문제가 있다는 것이 아니라, 아파치를 구성하는 것이 조심하지 않으면 함정에 빠질 수 있는 퍼즐을 푸는 것과 같다는 것입니다!

Oct 8, 2025 · 2 min read