Convert base64 into bytes[] & save in SQL as Image datatype

Forum to discuss the Web client version of Servoy.

Convert base64 into bytes[] & save in SQL as Image datatype

Postby Rakesh.Sharma » Tue Nov 14, 2017 4:56 pm

Hi All,

Can anybody suggest me. How to convert base64 into bytes[] in servoy web client.
Pass after conversion to DB for saving that bytes[] as into SQL Datatype Image.

Is there any Plugin available for it. Please suggest

Thanks in Advance.
Rakesh.Sharma
 
Posts: 2
Joined: Mon May 29, 2017 8:13 am

Re: Convert base64 into bytes[] & save in SQL as Image datat

Postby jdbruijn » Wed Nov 15, 2017 12:18 am

The svyUtils module has a function base64DecodeAsBytes in the scope svyCrypto.
Jos de Bruijn
Welcome CCS
Servoy Certified Developer
Image
jdbruijn
 
Posts: 453
Joined: Sun Apr 11, 2010 6:34 pm

Re: Convert base64 into bytes[] & save in SQL as Image datat

Postby juan.cristobo » Wed Nov 15, 2017 11:14 am

Also, you can use this:
Code: Select all
Packages.org.apache.commons.codec.binary.Base64.decodeBase64(string);
Juan
Madrid (Spain)

Servoy 7.4.x - MySQL / SQL Server 2008-2016
Windows 10 Pro
juan.cristobo
 
Posts: 180
Joined: Thu Apr 19, 2012 9:12 am

Re: Convert base64 into bytes[] & save in SQL as Image datat

Postby ROCLASI » Wed Nov 15, 2017 1:03 pm

juan.cristobo wrote:Also, you can use this:
Code: Select all
Packages.org.apache.commons.codec.binary.Base64.decodeBase64(string);


Which is what the svyUtils uses :)

Code: Select all
/**
* @private
*
* @param {String} encodedStr
*
* @return {Array<byte>}
*
* @properties={typeid:24,uuid:"B94FC7D2-63AC-4CAB-9A14-26F400C06842"}
*/
function base64DecodeAsBytes(encodedStr) {
   var b64 = new Packages.org.apache.commons.codec.binary.Base64();
   /** @type {Array<byte>} */
   var bytes = b64.decode(encodedStr);
   return bytes;
}

https://github.com/Servoy/svyUtils/blob ... yCrypto.js
Robert Ivens
ROCLASI Software Solutions / JBS Group, Partner
SAN Developer / Servoy Valued Professional / Servoy Certified Developer
Twitter: @roclasi / @servoyforge
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5225
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Convert base64 into bytes[] & save in SQL as Image datat

Postby juan.cristobo » Wed Nov 15, 2017 5:44 pm

Oh! :D :D :D
Juan
Madrid (Spain)

Servoy 7.4.x - MySQL / SQL Server 2008-2016
Windows 10 Pro
juan.cristobo
 
Posts: 180
Joined: Thu Apr 19, 2012 9:12 am


Return to Servoy Web Client

Who is online

Users browsing this forum: No registered users and 1 guest

cron