How to protect files in a hosted environment?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do you protect files (such as .PDF) in a hosted (Interland) environment
when you have no access to IIS?
 
The problem with the article is that you have to muck about with IIS. I don't
have that option in a hosted environment. Also, there is no protected
database subdirectory.
 
I don't think the ForbiddenHandler will work, since he does not have
access to IIS (to map file types to the ASPNET ISAPI).

The only solution I can think of is to store the files as binary data in
a database. SQL Server and Oracle have specifica column types for this
purpose. You would then create a custom httphandler (.ashx file, since
you cannot map a new file type) that handles retrieving the file data
from the database and sending it to the Response output stream. You can
figure out which file to retrieve using a querystring.

So:
http://myserver/application/Instructions.pdf
becomes:
http://myserver/application/FileLoader.ashx?file=Instructions.pdf
or:
http://myserver/application/FileLoader.ashx?fileID=110 (where 110 is an
ID column in the database that identifies the Instructions.pdf file).

Note, in the databse table, you will want to at least store the
filename, file contents (binary), and content type (so that you can set
the Response.ContentType when you return the data).


Joshua Flanagan
http://flimflan.com/blog
 
Protect them from whom? Do you have access to anyone else's hosted files on
the server? If not, what makes you think anyone else has access to yours?
And if nobody has access, in what way do you need to additionally protect
them?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
Back
Top