Blob and base64 of Oracle

Source: Internet
Author: User

The Blob and base64 of Oracle are used in recent projects. The scenario is to put images in the Oracle AS blob,
Then, in WS, It is encrypted with base64 and returned. . Net ,. . NET and then decode and restore it. Process summary:

1. It is relatively simple to upload images to BLOB fields in Java.

2. Use base64 to encrypt blob as follows:
Public static string iotobase64 () throws ioexception {
String filename = "D:/sunset.jpg"; // source file
String strbase64 = NULL;
Try {
Inputstream in = new fileinputstream (filename );
// In. Available () returns the object's Byte Length
Byte [] bytes = new byte [IN. Available ()];
// Read the content of the file into the Array
In. Read (bytes );
Strbase64 = new base64encoder (). encode (bytes); // converts a byte stream array to a string
In. Close ();
} Catch (filenotfoundexception Fe ){
Fe. printstacktrace ();
} Catch (ioexception IOE ){
IOE. printstacktrace ();
}
Return strbase64;
}

3. Net WebService receives this string and decodes base64, which is relatively simple in C # And saves things
webreference. helloworldimplservice H = new webreference. helloworldimplservice ();
string STR = H. returnbase64string ();
byte [] BS = convert. frombase64string (STR);
filestream file = new filestream ("C:/hello.jpg", filemode. create);
file. write (BS, 0, BS. length);
file. close ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.