...i own two domains ftp://mydomain.foo
and ftp://uploads.mydomain.foo
Users are able to upload zip files to ftp://uploads.mydomain.foo
I would like to create a "daemon", i guess with an ASP.NET handler, which will move the files from ftp://uploads.mydomain.foo
to ftp://mydomain.foo
at specified time intervals.
The problem is 开发者_Python百科that, i can not make sure that the list of available files for transfer, contains only files that finished uploading by the Users. (Not the ones that are been currently uploading).
How could i do that?
UPDATE: The daemon will actually be an Plesk cronjob which will call the ASP handler of mine.
File size information is available to your server as soon as the transfer is initiated. Hence, you can write a temporary file say ORIGINAL-FILE-NAME.mov.PART or something to show the original file name along with your flag telling you the file is still being uploaded to the server.
So if your other program is moving files from one server to the other, it will be looking for and find ORIGINAL-FILE-NAME.mov.PART and in-turn it will skip moving the ORIGINAL-FILE-NAME.mov to your other server.
To clarify, as the file is being uploaded your program will create the temporary .PART file, a flag to look for, and at the same time it will be actively creating the file being uploaded as well. So if you are actively uploading ORIGINAL-FILE-NAME.mov then the directory will have both these files in it:
ORIGINAL-FILE-NAME.mov
ORIGINAL-FILE-NAME.mov.PART
Once the upload is completed your program will delete ORIGINAL-FILE-NAME.mov.PART and you will be left with the actual uploaded file ready, its flag cleared and available for the next file transfer process.
That's how I'd do it.
精彩评论