Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have asked this question before but I got no answer. I am trying to get blob data from oracle and read it, than converting my Byte Array to base 64 so I can display later my image in my web page. But the problem is that my blobs are so huge, each array byte length is more than 1 500 000, so conversion is failed and an image icon is displayed instead of the real image. If I can't convert huge data to base64 is there another way to get images and display them? helps are more than appreciated!

What I have tried:

You can check the link mentioned above
Posted
Updated 19-Sep-16 22:34pm
v2

1 solution

It works for me:
Dim rawData As Byte() = File.ReadAllBytes("D:\Test Data\BigImage.jpg")
Dim base64 As String = Convert.ToBase64String(rawData)
Console.WriteLine("{0}:{1}", rawData.Length, base64.Length)

Gives me:
3489676:4652904
Which is an input image data file twice the size of the ones giving you problems. OK, I'm not reading my data from Oracle - it's coming from a file so I know it's a "large image" - but once it's in an array it's just data as far as the system is concerned.
So I'd start by looking at your code and working out exactly what you are doing, before deciding it's the conversion to base64 that is causing your problem.


"can you try to implement your converted image in img tag ?"


Works fine for me!
byte[] rawData = File.ReadAllBytes(@"D:\Test Data\BigImage.jpg");
string base64 = Convert.ToBase64String(rawData);
Response.Write(string.Format("<img src=\"data:image/jpg;base64,{0}\">", base64));

Dim rawData As Byte() = File.ReadAllBytes("D:\Test Data\BigImage.jpg")
Dim base64 As String = Convert.ToBase64String(rawData)
Response.Write(String.Format("<img src=""data:image/jpg;base64,{0}"">", base64))

Admittedly, my browser doesn't look pretty with a dirty great 3880x4997 image slapped into it, but...it works.
 
Share this answer
 
v3
Comments
H.AL 20-Sep-16 4:42am    
I know it is a problem with the conversion, what is the best solution to resolve this problem? Note that in my code byteArr.length is equal to imageBase64.length
OriginalGriff 20-Sep-16 4:55am    
How do you "know it's a problem with the conversion" when it works fine elsewhere?
What have you done that proves where the problem is? What error messages do you get, What code are you using?
H.AL 20-Sep-16 5:03am    
1- I tried an online converter from base64 to image and it did not work
2- I tried to change image format gif to jpg and png and it did not work
3- I tried to inspect element in the page itself I got the img with the src filled correctly, but image not displayed.
4- I implemented another src of an image converted online : it works normally
5- Blobs are filled in database by Oracle team
So shouldn't be a problem of conversion of large data? I know that your method is returning values of length, but mine too.
H.AL 20-Sep-16 5:12am    
can you try to implement your converted image in img tag ?
OriginalGriff 20-Sep-16 5:27am    
Answer updated

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900