We have images that are being base64 encoded and stored in a clob field in our db. the encoding and storing of the image is working fine. If I run this test to output some of the data to a string I can see there is info stored.
above code works as long as I hardcode the length of the string.
But what do I do if wanted to output the full string of the base64 code? For example this will return an error. Attempt to exceed maximum size of a CHARACTER variable. (9324). I understand that the string is beyond what a char field can store so how would you output the full value of a longchar value as string?
Secondly, if I just wanted to display the image inline this should work but it keeps returning errors.
Code:
<script language="speedscript">
def var v-b64-decod-str as longchar no-undo.
def var c as char no-undo.
def var v-str-length as int no-undo.
find record where bla blah ...
if avail record then
do:
copy-lob from img.image-name to v-b64-decod-str.
assign v-str-length = length(v-b64-decod-str).
assign codestring = substring(v-b64-decod-str,1,512).
end.
</script>
<head>
<title>test</title>
</head>
<body>
<textarea id="img" name="img" cols="75" wrap="VIRTUAL" rows="20" >`codestring`</textarea>
`v-str-length`
</body>
</html>
above code works as long as I hardcode the length of the string.
But what do I do if wanted to output the full string of the base64 code? For example this will return an error. Attempt to exceed maximum size of a CHARACTER variable. (9324). I understand that the string is beyond what a char field can store so how would you output the full value of a longchar value as string?
Code:
<script language="speedscript">
def var v-b64-decod-str as longchar no-undo.
def var c as char no-undo.
def var v-str-length as int no-undo.
find record where bla blah ...
if avail record then
do:
copy-lob from img.image-name to v-b64-decod-str.
assign v-str-length = length(v-b64-decod-str).
assign codestring = substring(v-b64-decod-str,1,v-str-length).
end.
</script>
<head>
<title>test</title>
</head>
<body>
<textarea id="img" name="img" cols="75" wrap="VIRTUAL" rows="20" >`codestring`</textarea>
`v-str-length`
</body>
</html>
Secondly, if I just wanted to display the image inline this should work but it keeps returning errors.
Code:
<script language="speedscript">
def var v-b64-decod-str as longchar no-undo.
find record where blah blah..
if avail record then
do:
copy-lob from img.image-name to v-b64-decod-str.
end.
procedure output-header:
output-content-type ("image/jpg").
base64-decode (v-b64-decod-str).
end.
</script>