B4J Question MySQL "TEXT" Types (maximum character sizes)

Harris

Expert
Licensed User
Longtime User

With regards to the above thread to SET the max session text size (websocket) for an upload, I have a question regarding the SAFE use of other MySQL text type definitions:

TEXT: max size is 65,535 characters... (default)
MEDIUMTEXT: max size is 16,777,215 characters..
LONGTEXT: max size is 4,294,967,295 characters...

Question:
Has anyone had any problem using MEDIUMTEXT type? (before I commit and find I made a big mistake)...

The reason why I ask...

I am creating an ABMaterial page for creating emails to send.
The editor I use allows the insertion of "images" embedded along with the standard text (as HTML).
While testing, SetMaxTextMessage(500000) - (websocket) works without error - BUT the server rejects it (does not save) due to size limit with TEXT field definition.
With MEDIUMTEXT - works fine.... - entire text size is less than SetMaxTextMessage(500000) and 16,777,215 characters for the field...

Of course, I wouldn't want anyone to store (or allow) GIG's of image data into a table, but rather let them set a template logo and (one or two) small sized images embedded in the email content to send to their selected client list.

Thanks
 

MicroDrie

Well-Known Member
Licensed User
Longtime User
The editor I use allows the insertion of "images" embedded along with the standard text (as HTML).
Unless you write the image as a base64 text string, the image doesn't look like text to me. In addition to the setMaxTextMessageSize, there is also a setMaxBinaryMessageSize. Maybe it will help if you increase that as well?

Update: setMaxBinaryMessageSize has used the StatusCode.MESSAGE_TOO_LARGE
 
Last edited:
Upvote 0

Harris

Expert
Licensed User
Longtime User
B4X:
<p class="ql-align-center"><img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4RTMRXhpZgAATU0AKgAAAAgADQEAAAQAAAABAAAIAAEBAAQAAAABAAAEgAEPAAIAAAAIAAAAqgEQAAIAAAAJAAAAsgESAAMAAAABAAEAAAEaAAUAAAABAAAAvAEbAAUAAAABAAAAxAEoAAMAAAABAAIAAAExAAIAAAAOAAAAzAEyAAIAAAAUAAAA2gITAAMAAAABAAEAAIdpAAQAAAABAAAA7oglAAQAAAABAAADAgAAA

This is what it looks like as stored in the table. The editor stores it as "data:image/jpeg;base64,"
Yes, the ws gets upset if you try and write beyond the MaxTextMesssageSize.
To prevent this error, I wrote a function to check the max text length before attempting to store...
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
The question is whether the base64 string is seen as plain text or as a binary text string. The ultimate test is to also set the setMaxBinaryMessageSize when an error occurs to see if the error disappears.
 
Upvote 0
Top