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 ();