Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsRepositoryRepositoryRepository: Displaying repository objects in ASP page - how to handle timestamp Repository: Displaying repository objects in ASP page - how to handle timestamp
Previous
 
Next
New Post
2/21/2006 2:14 PM
 

(I posted this on www.asp.net/forums, but it was suggested I post my question here. If you follow both forums, I apologise for the double-posting).

Hi,

I installed the Repository module on our public website, and we happily went along and loaded hundreds of docs. We used to have a simple asp app that listed all these documents using a file directory structure.

I just recently discovered that there's another app with a view out there, of the same folders, that I need to retain. This is an asp app that I can't "DNN-ify".

So ... I want to modify the asp app to read from the Repository's database structure to display its data.

So far, so good, I got the display from selected categories working, but ran into a problem with the timestamp the Repository adds. The filename in the db and the actual filename are not the same.

A sample filename from the db would be

W0002147_003.cdc266a7-9c09-40bb-8bd2-dff309407568.pdf

And the physical file may be

W0002147_001.someothertimestamp.pdf

I'm looking at the source code - downloader.aspx.vb and I can see that it strips off the extension, and then works from the first fullstop - so it seems to reconstruct to W0002147_003.pdf --> can't really see how this is useful though.

It's been suggested that I just use the W0002147, and search for the first file that matches this name, but if a user uploads the same doc more than once, I could end up displaying the wrong doc.

Can anyone shed some light on this for me, please?

Thanks!

________________________

Mikeh36 replies as follows:

A couple of reasons why the filename is changed.
1. Security - prevents direct linking to the files or people guessing what the filename is and getting around security permissions.

2. For the exact reason you mentioned about a user uploading the same doc more than once.

What the Repository does when you upload a file is it changes the name of the file to the same as what you're seeing in the db. Then when a user downloads it it strips that information out of the file before it goes to the user. I don't know if it's possible for you to do it in your ASP file or not but perhaps you can apply the same logic (stripping out the extra info) before the filenames are displayed.

 
New Post
2/21/2006 3:27 PM
 

Tinky_lou on the ASP.NET forum in reply to my post....
The thing is ... the filename in the db does not appear to be the same as the physical filename. I've uploaded specific files and then checked what is added to the database ... they don't match!

The Repository doesn't link to the document, it uses a function called "DownloadFile", which calls "StreamFile" with the full path as per database, and a "FileName", which is the filename with the timestamp stripped out.  DownloadFile uses System.IO.FileStream  to present the document.

Nowhere do I see a "translation" from one timestamp to another ... but it boggles me how it works if I can see the name + (version?) + timestamp for a newly created file in the db is not the same as the physical file I see on the server. How does it find the file?

The filename in the db does match the filename on the server (I just double checked on my dev DNN install). Possibly you're looking in the wrong directory if multiple files with the same name have been uploaded? If you do a search in your portal for one of the filenames listed in the db I guarantee you'll find it.

If you look at line 98 in Downloader.aspx you'll see a call to ExtractFileName which starts on line 554 of RepositoryBL.vb. What it does it finds the last "." in the filename. Then it loops backwards through the filename to find the next "." and strips out everything in between. Then it passes the stripped out filename back to Downloader.aspx so that you get the proper Save As indicator and the correct name for the file.

 
New Post
2/21/2006 6:01 PM
 

Thanks Mike! I just found the problem ...

I had to move the whole application a few weeks ago ... and didn't update the file upload locations for the module settings; so some files were still being uploaded to the old location and read from there. I, of course, was reading from the new location, and didn't pick up on this because the filenames are all pretty similar.

Goes to show: if the code shows it works just so  - it probably does!  

 
New Post
2/21/2006 6:09 PM
 
Good to hear you have it sorted out.
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsRepositoryRepositoryRepository: Displaying repository objects in ASP page - how to handle timestamp Repository: Displaying repository objects in ASP page - how to handle timestamp


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out