Re: jpg file to blob in MySQL
- From: JScoobyCed <pim@xxxxxxxx>
- Date: Thu, 15 Jun 2006 10:46:20 +0700
Ike wrote:
> I am reading a jpeg file into a byte []:
>
> File flimage = new File("c:\temp.jpg");
> byte[] b = new byte[(int)flimage.length()];
> try{
> InputStream isImage = new FileInputStream(flimage);
> isImage.read(b);
> }catch(Exception e){
> e.printStackTrace();
> return null;
> }
>
> It returns a valid byte[].
Is the actual content of this byte[] the same as the image file? I.e.:
- was the file read fully?
- saving this byte[] back to a FileOutputStream with different name gives a correct image?
- use this byte in your next code (the one to display the image from the blob) and see if it works
Another option would be to convert the initial byte[] (from the inputstream) to a non-binary array (base64 or hexa values) and save it to the blog. Then when reading it back, converting to the original format. But this solution needs processing time and takes more space in the DB.
--
JSC
.
- References:
- jpg file to blob in MySQL
- From: Ike
- jpg file to blob in MySQL
- Prev by Date: Getting null when call execute() on a stored proc in sybase
- Next by Date: Problem with weblogic 8.1SP5
- Previous by thread: jpg file to blob in MySQL
- Next by thread: Getting null when call execute() on a stored proc in sybase
- Index(es):
Relevant Pages
|