473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

get image with httpwebrequest to stream to byte array to base64

I was make an function which reads file from windows path and read that image
with bytereader I able to make it,
Then I try to get that image from httpwebrequest but I get convert'ing
problems
stream to string to byte[] to base64?

HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(imagelink);
HttpWebResponse myResponse=(HttpWebResponse)myRequest.GetResponse( );

Stream mystream=myResponse.GetResponseStream();
StreamReader mystreamReader=new StreamReader(mystream);

string result=mystreamReader.ReadToEnd();

byte[] mybytes;
mybytes=new System.Text.ASCIIEncoding().GetBytes(result);

returnstring+=Convert.ToBase64String(mybytes);

Thanks for your help.

Nov 19 '05 #1
1 8827
Esref DURNA wrote:
I was make an function which reads file from windows path and read
that image with bytereader I able to make it,
Then I try to get that image from httpwebrequest but I get convert'ing
problems
stream to string to byte[] to base64?

HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create(imagelink); HttpWebResponse
myResponse=(HttpWebResponse)myRequest.GetResponse( );

Stream mystream=myResponse.GetResponseStream();
StreamReader mystreamReader=new StreamReader(mystream);

string result=mystreamReader.ReadToEnd();

byte[] mybytes;
mybytes=new System.Text.ASCIIEncoding().GetBytes(result);

returnstring+=Convert.ToBase64String(mybytes);


Don't use TextReaders to read binary data! Simply consume the
ResponseStream.

Cheers,

--
Joerg Jooss
www.joergjooss.de
ne**@joergjooss.de
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bo | last post by:
Hi I have an array of int that represents a frame buffer, which I update dynamicly. Each int is 0xAARRGGBB. In standard java I can use imageProducer to create an Image object. In J2ME there...
6
by: Luis Arvayo | last post by:
Hello, I am trying to convert a jpeg image stored in a PictureBox to a byte array in order to later save it to a database, but I get this error : "Generic Error in GDI+". The source code is...
1
by: Jim Hammond | last post by:
How can one bind a database image column (the byte array - not the path) to a datagrid column? The closest thing I have found so far is this January 2002 statement by Dino Esposito: "Likewise,...
5
by: topdawg147 | last post by:
I'm trying to convert an image to a byte array. However, when i do this something is getting changed in the bytes (contents, length, etc). I know because I'm also looking at the image bytes in a...
2
by: Don | last post by:
Is there any way to convert an Image into a Byte array that does not require saving the image to disk? - Don
3
by: JamesB | last post by:
I am saving image files from my website using the downloaddata on the web client. This gives me a byte array, which I am then saving to a file with the following code: ' Create the new, empty...
8
by: piggy | last post by:
I am trying to convert an image to an byte array (tobytes() method) and from byte array back to an image (frombytes() method). The problem i have here is say the image size is 285 bytes but the...
5
by: Trapulo | last post by:
Hello, I need to send to a webservice a parameter that is a string containing an XML doc. In this xml, a node value came from a byte array (it's an RSA signature). What is the best way to convert...
2
prabunewindia
by: prabunewindia | last post by:
hi friends, i want to store the file in byte array. plz help me. i am thinking we have t odo it thru file stream. i tried. but not getting how to use filestream plz help Prabu
8
by: anandmms | last post by:
Hello friend, my problem is to save more than one fingerprint images in one byte array and then store in database(oracle). i dont know how to solve it. But previously i had did image saving...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.