Document management (Full Version)

All Forums >> [Web Development] >> General Web Development



Message


yogaboy -> Document management (11/17/2005 8:00:52)

Does anyone know of any good sites with stuff about document management?

What I want is to hide the source of the doc, hide urls, stream it to the client etc etc.

I'm looking for big-picture stuff, I'm not worried about the languge, I'll be writing it in c#, but I'm most interested in the concepts - so that when I start coding there's not an important aspect I've not thought about/planned for.

Any help is much appreciated.




bobby -> RE: Document management (11/17/2005 11:54:24)

I've been playing with an ASP script from Spooky that prompts a download for a file, without showing the source URL...

something like that?





yogaboy -> RE: Document management (11/17/2005 16:47:03)

yes something like that. It's difficult finding anything on the web using the words "file", "download" and "url" in search engines![:D]

If you've got that script or any thoughts on the subject I'd be really interested to hear them.


Just found this by luck - very good comments. It's in VB.NET but good stuff nonetheless.




bobby -> RE: Document management (11/17/2005 17:29:03)

<%@ Language=VBScript %>
<%Response.buffer=True

'///////////////////////////////////////
'// This is the server path to your files (it WILL need changing)
'///////////////////////////////////////

filePath = "c:\http_root\file\"

'///////////////////////////////////////
'// First, see if the user has logged in
'///////////////////////////////////////

'///////////////////////////////////////
'// Request file name from link query string
'///////////////////////////////////////


fileName = request.querystring("file")

'///////////////////////////////////////
'// Log the download
'///////////////////////////////////////

' Insert logging code here
' Eg - record the user and download in a seperate dataabse / text file


'////////////////////////////////////////
'// Send the file.
'// The file is sent to the user, using the code "download.asp?f=filename.ext"
'// So, if the file is called setup.zip, youll use a link "download.asp?f=setup.zip"
'//
'////////////////////////////////////////


Response.ContentType = "application/asp-unknown"
Response.AddHeader "content-disposition","attachment; filename=" & fileName
Set FStream = Server.CreateObject("ADODB.Stream")
FStream.Open()
FStream.Type = 1
FStream.LoadFromFile(filePath&filename)
Response.BinaryWrite FStream.Read()
FStream.Close
Set FStream = Nothing
Response.End

'////////////////////////////////////////
%>







yogaboy -> RE: Document management (11/17/2005 19:20:31)

Thanks Bobby, looks very similar to the one on the link - that's helpful, means I have to think less! [:)]

Here's what I've come up with, possibly a few holes but I'm certainly no expert on VB to C# (or even just c#!)

private void Page_Load(object sender, System.EventArgs e)
		{
                     //put an if block around SendFile2Stream to satisfy your auth levels

                     //pass the querystring with the filename to the method
			SendFile2Stream(Request.QueryString[0]);			
		}

              //method for sending the file to the output stream
		private void SendFile2Stream(string filename)
		{
                     //declare local variables
			FileStream fs = null;
			byte [] bytBytes = null;

                     //try block
			try
			{
                            //open the filestream to the document
                            //note" Configuration.WebsiteDocsPath is a class-property I've got to get useful keys from the                  
                            //web.config
				fs = new FileStream(Configuration.WebsiteDocsPath + filename, FileMode.Open, FileAccess.Read);
                            //create a byte array of doc's length
				bytBytes = new byte[fs.Length];
                            //read the filestream into the array
				fs.Read( bytBytes, 0, Convert.ToInt32( fs.Length ) );
			}
                     //should be some catch blocks here!!!

                     //don't cross the streams! :)
			finally
			{
				fs.Close();
			}

                     //add the headers
			Response.AddHeader( "Content-disposition", "attachment; filename=" + filename );
                     //pick a content type
			Response.ContentType = "application/octet-stream";
                     //write the doc to the output stream
			Response.BinaryWrite(bytBytes);
                     //end
			Response.End();
		}//end method


It worked for me so far...but

I didn't add any exceptions yet as I'm sure there are lots and lots for the file/stream objects and I don't want to mislead anyone by leaving them out/just using the general exception. I also left out the authorization "if", as that can be sorted out according to one's own fascist desires (I've got a few of those).





Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.0625