What size should I set to store a Base64 string in a VARCHAR field?

Asked

Viewed 373 times

1

I need to store an image that is in Base64 in the mysql database...

My doubts are:

1 - I must compress this string before saving to the bank, if yes what is the best way to do this?

1.2 - The Base64 image is generated in the client-side, so I must compress the string in the client or server-side...to then store in the database?

2 - I need to create a VARCHAR column with the maximum size/value in mysql? inserir a descrição da imagem aqui

Follow the image url: https://pastecry.pt/bYwnq6#GamYmVeq%23Yh1Suh2Feq3Nup0Kew


In the general context, I plot using the amCharts library on a page and take a print with html2canvas (Base64).

I need to store this image in the database to later bring the image in a pdf when necessary.

Follow the page with the chart: http://evolvetihost.com.br/sites/d3coaching/dev/resultado.php?nome=teste&phone=5545376586759&[email protected]&estado=Al&idade=2&genero=Male & marital status=Single(a)&perfeccionista=100&vitimista=100&dominator=100&ajudante=100&auto_sacrificio=100&inseguranca=100&inflexibilidade=100&postura_punitiva=100&negativismo_e_pessimismo=100&subjugacao=80

At the end of the page has the image in hidden Base64, her src is assigned in a variable, which I intend to send to the bank via ajax...

  • 2

    I even tried to answer, but the first two the answer is: only you know, we have no way to answer to you, not without requirements, if it were to always do a way would already be ready. I’d probably wear one TEXT and not VARCHAR. To tell you the truth I wouldn’t use Base64 to record, but you can do as you see fit and meet your need.

  • @Maniero, in the general context...eu I get a chart using the amCharts library, and need to store a print of this result (graphic), to later bring the image in a pdf when requested.

  • @Maniero, about the first two questions are related to my fear of saving this Base64 long string in this way and having problems with the bank in the future...

  • 1

    Take all the graphics you’ve ever done and look at the biggest of them, add a few extra bits to make sure and that’s it, you’ve got the size you need

  • @Costamilam, good tip...I created the column as TEXT in the bank, and I’m already saving it...I managed to select and bring the image in the pdf correctly in an acceptable loading time.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.