Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preserving Timestamps of Uploaded Files

Status
Not open for further replies.

bboffin

Programmer
Nov 26, 2002
553
GB
I am developing a web application that allows remote users to store binary files on a remote server over the general internet. I have looked at a number of Upload controls but they all suffer from one problem. The original file's Creation and Last Modified timestamps are not preserved or passed to the server.

These timestamps are essential as they provide a precise definition of the version of the file that has been uploaded and this provenance needs to satisfy the legal profession.

I have coded a solution that uses the MS FileSystemObject to get the data and pass it in hidden fields but this is inappropriate for general use as many clients have secure IT policies that forbid the use of ActiveX controls like this.

The problem appears to be that all the controls use the basic <input type=file ... element to pass the file name and this does not preserve the timestamps.

Can anyone suggest a way round this problem?


Bob Boffin
 
The original file's Creation and Last Modified timestamps are not preserved or passed to the server.
That's not strictly true. When a file is uploaded and saved to the server, the creation date of that file is that precise date when it was saved to the server - yes, it may have been created at an earlier date on another pc, but on the server that is when it was created.

You may be able to get to the file attributes before it is saved to the server (i.e. from within a stream) and retrieve the dates from there, but I'm not sure if even that will work or not so you'll just have to do some testing.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks for your comments but I'm afraid that what I said is precisely true. The timestamps given to the file on the server are of no value to me. After considerable testing it is apparent that none of the metadata associated with the original file is passed through in the upload stream.


Bob Boffin
 
Thanks for your comments but I'm afraid that what I said is precisely true.
No, what I said was that the new date of the file (i.e. when the file is saved to the server) is the correct creation date of that particular instance of the file regardless of what date you think it should contain.

If you want the creation date of when the file was created on a users machine, you'll have to try my suggestion of looking at the date from withing the stream, bu again as I said, I don't know if that will work so you will have to do some testing on that.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I have decided to look at writing a freestanding FTP program that will be supplied to users. This will also send any additional metadata (such as file description and cost center) via a web service. FTP can (and usually does) preserve the original timestamps.

In many cases this file will also be submitted to a Version Control System for storage so it must be created with the original timestamps.

The uploaded file will always be either moved to a more permanent folder or deleted after being added to version control.


Bob Boffin
 
FTP can (and usually does) preserve the original timestamps.
I don't think you understand the "instance" part of what I was trying to say.

Think of the file that is on the client as "Instance 1" of the file and the file that is uploaded to the server as "Instance 2". "Instance 1" may have been created months ago but when you upload the file to the server "Instance 2" is created there and then on the server and therefore has a created on date of today.

It's irrelevant whether you use FTP or HTTP to create the second instance (as I've just proved in testing as "Instance 2" always has todays date).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I think that this has degenerated into pedantry on your part. Of course when a copy of the file is first created on the server it gets the creation time stamp of that instant but this can be overwritten subsequently and that's all I'm trying to do.

The FTP protocol (and even the file copy feature of Explorer) does this as a matter of course.



Bob Boffin
 
You've misunderstood my post if you think I'm being pedantic.

I've just done a simple test with two FTP clients (via WS_FTP and using DOS) and transferred a file that was created 3 months ago to a server. When you look at the file on the server it has a creation date of today which is what it should have.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
These timestamps are essential as they provide a precise definition of the version of the file that has been uploaded and this provenance needs to satisfy the legal profession.
I imagine it would take forensic analysis - of the original hard disk to satisfy the legal profession. It's too easy to set the timestamp to whichever date you choose.

If the date and time are that important, have them mail you the CD in an envelope which stays sealed (thus preserving the provenance of the post-marked date).


It sounds like version control is the most important aspect, in which case you should look into running a version controlled repository such as CVS or Subversion. The obvious advantage of version control over a date-dependant upload is that it isn't dependant on an unreliable information source such as a datestamp. Typically, it'll also handle issues such as upload collision, forking, and rollback.

Subversion provide a good windows client (Tortoise SVN) which integrates nicely with the windows shell.

Either way, you're not going to achieve this via a simple web service unless the user deliberately allows this (through permitting ActiveX, a Java applet, or downloading some sort of standalone client).

---
Marcus
better questions get better answers - faq581-3339
accessible web design - zioncore.com
 
Try setting the 'Preserve file time on transfers' option for the site in WS_FTP LE or Pro. This makes sure that an upload behaves just like a download (where the timestamps of the original file are preserved automatically) provided that the server allows it. Since I have control of the server this will be the case.

The point is that for my application to be viable the time stamps of the original must be available to me as the upload constitutes a legal process and the end user must be able to view this information as confirmation that the file is a copy of the original in all respects.

All I need is a way to obtain this information and it isn't in the stream.


Bob Boffin
 
Ah yes, but those FTP programs that do allow you to do that are windows based not web based. That means that they do have access to the FileSystem and can therefore read the creation date before uploading it to the server and then overwrite the file's creation date on the server. This simply isn't possible via the web (although you may be able to write an ActiveX component as long as your users are using IE and they accept the script).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
So the short answer is it can't done except by using a free standing windows program that uploads the file via ftp or a web service as I suggested.


Bob Boffin
 
Well yes, it's irrelevant of how you upload the file - it's getting access to the original file in the first place which, fairly obviously, would be a major security risk in a web environment and therefore not possible (unless you take the ActiveX route).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top