WebRequest Filename

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I am trying to create a downloader which will bypass the saveas box in the
WebBrowser control. I have the file downloading, but I don't know what the
filename is that is being passed through the stream. Is their a way to
determine what the file name is so that I can execute the appropriate
functionality of the extensions. The stream is created dynamically so I
cannot capture the filename straight from the URL.


Thanks
STeve
 
Steve,

Can you explain this more, because this sounds like plain hacking.

Cor
 
Thus wrote Steve,
I am trying to create a downloader which will bypass the saveas box in
the WebBrowser control. I have the file downloading, but I don't know
what the filename is that is being passed through the stream. Is
their a way to determine what the file name is so that I can execute
the appropriate functionality of the extensions. The stream is
created dynamically so I cannot capture the filename straight from the
URL.

I don't really understand what you're trying to achieve.

Either you know the file name already, because it's part of the URL, like
http://host/path/to/file.foo --> file.foo is your file name. Actually, the
real file name might be completely different on the server side, but you'll
never find out, depending on what actually happens on the server side.

Or you're accessing a resource without any file component in the path, like
http://host/path/to -- if the server redirects that request internally, you
also never know what the file name on the server side was. If the server
redirects you externally, the former case applies.

Cheers,
 
The website is runing a JSP which determines which file to send. In order
to download a file using the WebBrowser, we have caught the link to the JSP
and cancelled the navagating (thought the Navagating event of the
webBrowser). We then download the file using the client application. The
problem is that I do not know the filename as it is sent down via a stream
without the filename attached (or at least I don't know how to determine the
filename). If you executed the link in IE or Firefox normally, the saveas
dialog will popup with the filename. I want to know how I can determine the
filename using the WebRequest etc. so that I know what file is being sent
and how to execute the file. ie. Zip, xml, doc, etc.

Most samples I have looked at have the filename linked to the URL and they
just parse out the filename. My URL is a simple JSP and therefore I can't
tell what the filename is.

Steve
Cor Ligthert said:
Steve,

Can you explain this more, because this sounds like plain hacking.

Cor
 
Steve,

That they have protect it with JSP means that they won't allow you to use
the real dataname, in other words, trying to get a file direct means in most
countries hacking.

Just my idea,

Cor

Steve said:
The website is runing a JSP which determines which file to send. In
order to download a file using the WebBrowser, we have caught the link to
the JSP and cancelled the navagating (thought the Navagating event of the
webBrowser). We then download the file using the client application. The
problem is that I do not know the filename as it is sent down via a stream
without the filename attached (or at least I don't know how to determine
the filename). If you executed the link in IE or Firefox normally, the
saveas dialog will popup with the filename. I want to know how I can
determine the filename using the WebRequest etc. so that I know what file
is being sent and how to execute the file. ie. Zip, xml, doc, etc.

Most samples I have looked at have the filename linked to the URL and they
just parse out the filename. My URL is a simple JSP and therefore I can't
tell what the filename is.

Steve
 
So why is it that if I save it using IE or Firefox, it brings up the name of
the file?

Steve
Cor Ligthert said:
Steve,

That they have protect it with JSP means that they won't allow you to use
the real dataname, in other words, trying to get a file direct means in
most countries hacking.

Just my idea,

Cor
 
Steve


What you want to do is in my idea at the edge, not real dotNet and certainly
not something for a newsgroup like this.

Cor

Steve said:
So why is it that if I save it using IE or Firefox, it brings up the name
of the file?

Steve
 
Steve said:
I am trying to create a downloader which will bypass the saveas box in the
WebBrowser control. I have the file downloading, but I don't know what the
filename is that is being passed through the stream. Is their a way to
determine what the file name is so that I can execute the appropriate
functionality of the extensions. The stream is created dynamically so I
cannot capture the filename straight from the URL.

Have a look at the Content-Disposition header. It should be something
like:

attachment; filename=myfilename.dat

Parse that to get the filename, then save the file appropriately.

(I'm not sure why Cor would think this is hacking - it's not
"protected" by a JSP at all, just served by one, by the sounds of it.)
 
Jon,

We protect on our website our emailadresses by javascript. We do that not
for nothing. I am certainly able myself to get those if somebody else does
that. I am not known with JSP, but if it would be on a ASP page where
original pictures where placed in a database or in a special protected
directory, than the retrieval of that would be seen by me as a kind of
hacking.

As I wrote for me is this going on the edge. You probably can say as long as
the folder is not protected on internet it is free, I am in doubt if that
theorie from the begin of internet will be seen at the moment like that by
any judge in any country.

But just my thought about it.

Cor
 
Cor Ligthert said:
We protect on our website our emailadresses by javascript.

That's obfuscating the HTML - there's no obfuscation going on here. The
Content-Disposition header is a perfectly normal one, there's no extra
trick involved. It's just a case of using that as part of WebRequest.
We do that not
for nothing. I am certainly able myself to get those if somebody else does
that. I am not known with JSP, but if it would be on a ASP page where
original pictures where placed in a database or in a special protected
directory, than the retrieval of that would be seen by me as a kind of
hacking.

In this case the OP can download the file and be presented with the
filename when he's downloaded it. How is automating that "hacking"?
As I wrote for me is this going on the edge. You probably can say as long as
the folder is not protected on internet it is free, I am in doubt if that
theorie from the begin of internet will be seen at the moment like that by
any judge in any country.

All the OP wants to do is emulate the browser's reaction to the
Content-Disposition header. The filename isn't being "protected" by the
JSP - it's coming down as a header in the normal way! It's just easier
(presumably) for the site to serve the pages with a JSP than to make
the filename available as part of the URL. That's often the case when a
file is served from a database or something similar.
 
Thanks Jon,

This is exactly what I have been looking for. I guess I just didn't know
what header to search through.

Thanks again
Steve

This is exactly what I was looking for. I looked at the headers in MSDN
 
Back
Top