이미지 base64로 인코딩, 디코딩

김듑듑·2022년 10월 14일
0

프론트엔드

목록 보기
17/24

원래는 백으로 formdata 만들어서 blob으로 이미지 보내는데 아무튼 내가 이미지 생성을 data:image/png;base64,어쩌고저쩌고 이렇게 했기때문에 알아야함

아무튼 필요할때가 있다


atob이거 왜 못쓰고 buffer.from 쓰라고 하네 킹받네 그냥 쓰라고하면 안되냐

'atob'의 시그니처 '(data: string): string'은(는) 사용되지 않습니다.ts(6387)
buffer.d.ts(2214, 12): 선언이 여기에 사용되지 않음으로 표시되었습니다.
예 안됨
function atob(data: string): string (+1 overload)
Decodes a string of Base64-encoded data into bytes, and encodes those bytes into a string using Latin-1 (ISO-8859-1).

The data may be any JavaScript-value that can be coerced into a string.

This function is only provided for compatibility with legacy web platform APIs and should never be used in new code, because they use strings to represent binary data and predate the introduction of typed arrays in JavaScript. For code running using Node.js APIs, converting between base64-encoded strings and binary data should be performed using Buffer.from(str, 'base64') andbuf.toString('base64').

@since — v15.13.0, v14.17.0

@deprecated — Use Buffer.from(data, 'base64') instead.

@param data — The Base64-encoded input string.

그래서 버퍼를 썼는데 진짜 개킹받네ㅠ

Buffer is not defined

https://stackoverflow.com/questions/23097928/node-js-throws-btoa-is-not-defined-error

0개의 댓글