Using FileStream object to read JPEG File from Https location.

G

Guest

Hello all -

This has been frustrating me long enough that I'm willing to appeal to the gurus out there to put this in my rear view mirror. I'm trying to access a JPEG file that I have within my website but need to show within a Crystal Report. I setup a disconnected dataset that has 1 column and I can read the image into the dataset fine if I use a path like below:

\\webserv\wwwroot\prodsite\images\1.jpg.

The moment I try to use the filestream to read from this location below (FYI prodsite.com is obviously to protect the privacy of the real site):

https://www.prodsite.com/images/1.jpg

It gives me a message of "The given path's format is not supported" (This also goes for 'Http'). If I can't use a filestream object to read the bytes of this image into a dataset in the report, what other options are available that are simple at this point?

Much thanks for any thoughts,
Mark
 
J

Joerg Jooss

=?Utf-8?B?TWFyaw==?= said:
Hello all -

This has been frustrating me long enough that I'm willing to appeal
to the gurus out there to put this in my rear view mirror. I'm
trying to access a JPEG file that I have within my website but need
to show within a Crystal Report. I setup a disconnected dataset
that has 1 column and I can read the image into the dataset fine if
I use a path like below:

\\webserv\wwwroot\prodsite\images\1.jpg.

The moment I try to use the filestream to read from this location
below (FYI prodsite.com is obviously to protect the privacy of the
real site):

https://www.prodsite.com/images/1.jpg

It gives me a message of "The given path's format is not supported"
(This also goes for 'Http'). If I can't use a filestream object to
read the bytes of this image into a dataset in the report, what
other options are available that are simple at this point?

System.Net.WebClient and System.Net.WebRequest will allow you HTTP(S)
downloads.

Cheers,
 
G

Guest

Hi Joerg -

I appreciate you getting back to me with your suggestions. Since I'm not too familiar with WebRequest or WebClient ever before, is there an example that could possibly point me to as a guide

Much thanks

Mar

System.Net.WebClient and System.Net.WebRequest will allow you HTTP(S)
downloads

Cheers
 
J

Joerg Jooss

=?Utf-8?B?TWFyaw==?= said:
Hi Joerg -

I appreciate you getting back to me with your suggestions. Since
I'm not too familiar with WebRequest or WebClient ever before, is
there an example that could possibly point me to as a guide?

Well, there's always MSDN ;->
-- but to get you started, check out this method:

public void Get(string uri) {
WebClient client = new WebClient();
byte[] response = client.DownloadData(uri);
// write resposne to a file, put in a database or whatever you
// need to do
}

Just make sure to handle WebException when calling this method:

try {
Get("http://foo.bar.com/image.gif");
}
catch (WebException ex) {
}

For basic HTTP downloads, that's pretty much it. The WebRequest class
gives you a much more fine-grained control of the HTTP conversation, but
for a simple file download, WebClient is sufficient.


Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top