question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Send Base64 Image

See original GitHub issue

Hello, I’m trying to send a Base64 string but can’t figure out how, I’m only getting this error:

UnhandledPromiseRejectionWarning: Error: 500: Unsupported http response from Telegram
    at buildConfig.then.then.then.then (/home/alberto/Documentos/tg-nim-tip-bot/node_modules/telegraf/core/network/client.js:263:17)

Code: ctx.replyWithPhoto(base64) The file string looks like this:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAnYAAAQkCAYAAADwwlM/AAAABmJLR0QA/wD/AP+gvaeTAAAgAElEQVR4nOy9SawkSbYddsx8ijnekGNV1thVXVMPv/X7T8IHAe5ECRAEcidAAhdaChDAlShAAiEQAiVAEARwJXAlSNwQJKiFBC21IP5Adv/u/3us7q7qrjkrM1++OSJ8MtPC7JqZ+4uIF4N7RLyXftDVOb0IH8LD/Pi5557LsAaklAcAvg/g9wB8AOAVAA8A3AfAAeyt8/4NGjRo0KBBgwa3ECcABICvATwG8BmAnwH4MYAfMMaer/rGbNkXSClfBfCfA/iPAPwBAG/VjTdo0KBBgwYNGjQoIAfw7wD83wD+d8bYp8u8eGFiJ6X8IwD/HYD/AEqNa9CgQYMGDRo0aFAfBID/F8B/zxj7y0VecC2xk1I+BPBPAfzd9fatQYMGDRo0aNCgwYr4VwD+S8bYV/N+aC6xk1L+JwD+GYDDCnesQYMGDRo0aNCgwfI4AvBfMMb+9awfmFlSlVL+VwD+JRpS16BBgwYNGjRosAs4BPCvpJT/aNYPTFXspJT/AMD/XNNONWjQoEGDBg0aNFgP/4Ax9r+U//IKsdPl13+JpkGiQYMGDRo0aNBgVyEA/L1yWbZA7HSjxE/QlF8bNGjQoEGDBg12HScAvs0Y+5z+oqzK/VM0pK5BgwYNGjRo0OAmYA/A/+r+hVHspJR/AOAvsUJocYMGDRo0aNCgQYOt4U8YY38BFBW7f4SG1DVo0KBBgwYNGtw0/Lf0GwYAUspHAH6HisaDfTm5xA9OnuKHp8/w84tjnKUJTrMEp2mCWORVbKKApdioBDhj8BhDxD10PR8eY0iFQCxyjEWGVIjK93Ed0L5G3EPL8+AxhkxIZFLtcyIEUikgpFx7WzvL7J1D44yBQ32G9Fl6pb/jjMGD+pWOSUBCSgkBCSEBYX4vISGRSwkB/feFf0Ml53YR7ML59xhDwDgCzhFwz/weAF...

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
victor-iaroscommented, Jan 14, 2020

bot.telegram.sendPhoto(chatId, {source: Buffer.from(imagestring, ‘base64’)} ); or ctx.replyWithPhoto( {source: Buffer.from(imagestring, ‘base64’)} )

take note that the imagestring should not include ‘data:image/png;base64,’

1reaction
ejnshteincommented, Aug 8, 2019

-> https://telegraf.js.org/#/?id=working-with-files if you want to send base64 i think it’s better to convert image to Buffer first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Send a base64 image in HTML email - Stack Overflow
The image appears and displays properly in the web page after they submit. Since the image is not uploaded anywhere, the editor saves...
Read more >
How to upload files from your HTML form using ... - Formcarry.
Learn how to quickly encode your file input content as Base64 Data URI and save it to your server.
Read more >
Base64 Image Encoder - Convert any image file or URL online
With Base64 Image Encoder, you can convert any image file or URL to either Base64, HTML, CSS, JSON, or XML online. Everything happens...
Read more >
How to upload files from your HTML form using Base64 ...
In our example, we will upload the image file by encoding the image as Base64. First, let's write simple HTML and set the...
Read more >
How To: Base64 Image Transfer with Swift & Python - Medium
To convert an image into a JSON-friendly format, we can use Base64 encoding. In short, Base64 converts a binary representation (an image file) ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found