Devlog/Web
[Axios] URL 링크를 통해 이미지를 받았을 때, Base64로 컨버팅하기.
Damien.Lee
2021. 4. 2. 20:23
반응형
await axios.get('http://SITE_NAME.com/IMAGE_NAME.jpg', {
responseType: 'arraybuffer'
}).then(async (res) => {
const imageData = res.data;
const buffer = Buffer.from(imageData, 'base64');
...
...
});
핵심은 Axios Request Config 의 responseType을 'arraybuffer' 로 설정 해주는 것.
반응형