hacker has asked for the wisdom of the Perl Monks concerning the following question:

I am in the process of designing a portion of a website that will allow users to convert documents to a particular format by either:
  1. Point to a file resource via URI (i.e. http://www.foo.com/foo.pdf)
  2. or
  3. Upload a file to the server for server-side conversion
When the server is pointed to a remote resource, I can convert that, and this part works today without any problems.

I want to add the capability of having the users upload a file from their local system to the server for conversion (limited by $maxsize, of course). The hitch here is that I need to provide a way for the users to be able to delete the file from the server after they've uploaded it. I don't want to deal with the hassle (or risk) of housing their data on my server, or that they think it's insecure (we all know it is).

Yes, I could easily just copy the file where the script can't find it at deletion time, and they'd "think" it was deleted, but I'm not maliscious like that. It's a matter of policy as well as implementation.

Has anyone done something like this? I have a few approaches:

  1. Common upload/ftp directory, bad.
  2. Browser-based file upload with browser-based deletion
  3. Login:pass authentication to their "account" on the server, where their uploaded files exist (something like FreeDrive or similar places) and then they can add/delete into their "account" as necessary.

Replies are listed 'Best First'.
Re: Browser-based file uploads and deletions for a
by kwoff (Friar) on Nov 18, 2001 at 03:58 UTC
    Does the file necessarily have to be stored on the server? I wouldn't rely on the user to delete the file. When you use CGI.pm, you get the uploaded data with a filehandle you read from like
    while (<$upload_fh>) { $file_contents .= $_; }
    Why do you need to store the file at all? Anyway, CGI.pm temporarily stores uploaded files in a /tmp directory (look for the -private_tempfiles "pragma" in `perldoc CGI`).
      The users need to "know" that the file has been deleted. I don't want them claiming I'm keeping their files. Now we're back to policy over implementation though.

      "Do not upload files that you view as private or proprietary"

      I'll keep banging out some ideas. Thanks.

Re: Browser-based file uploads and deletions for a
by atlantageek (Monk) on Nov 18, 2001 at 05:53 UTC
    How astute is the common use of this application. No matter what you can copy the file while processing. If this is a common user I think you can just use a browser base upload but don't use the upload terminology. Something along the lines of saying process (not upload) and never actually storing the file on your machine (or you do and just never let them know. If you did use a non-browser upload how will the processing be triggered? Just an ide.s ---- I always wanted to be somebody... I guess I should have been more specific.

      I think you're right, atlantageek. This is really a question of social engineering and trust. If you call it "convert" or "process", rather than "upload" I bet 99% of folks wouldn't have an issue with it.

      If it were me, I'd just write it so that the subroutines I use to do the conversion unlink() the files right after processing. Maybe you could write a sub that opens and prints the document (with the correct mime-type, of course) to tbe browser, and as its last action it unlinks the file. (Don't forget binmode if you're on windows) As long as the user doesn't press "stop" and the download of the converted document completes, you should have no record of the file being there, and it's essentially a download once system.

      -Any sufficiently advanced technology is
      indistinguishable from doubletalk.

Re: Browser-based file uploads and deletions for a
by kha0z (Scribe) on Nov 18, 2001 at 15:12 UTC

    I appears to me that your question is not so much as to how to handle the conversion but how to present your product or service to your users. In this sense, I think you need to really ask yourself, "What is the goal of my file conversion service?"

    First, if you are not going to be providing this service for classified documentation then you don't really need to worry about what the end user thinks the security of their files are. Like you stated, we all know that transmission over http is insecure. So, maybe you need to look at developing a terms of service agreement that will release you of any liabilites including copyright and patent rights that the end user may claim to have for using your service. In this sense then you can worry about the disk space problems and clean up yourself that a simple cron job or perl script can solve.

    However, if you are going to offer a corporate level solution then a free iDisk idea is perhaps the best idea. But dont try to make your users feel safe. Use the appropiate security measures such as secure http and ssl.

    This decision lies in your hands. "Keep it simple. Enlightenment will come to you as long as your motivation is true."

    Good Hunting,
    kha0z

Re: Browser-based file uploads and deletions for a
by sevensven (Pilgrim) on Nov 19, 2001 at 05:31 UTC

    "I want to add the capability of having the users upload a file from their local system to the server for conversion (limited by $maxsize, of course). The hitch here is that I need to provide a way for the users to be able to delete the file from the server after they've uploaded it.

    Have you considered using webdav for uploading/deleting of files ?

    Webdav is supported by Apache and IIS (among others) and allows clients to upload files, change or delete them. Internet explorer is a webdav client and works ok with Apache webdav, just do a File/open, indicate the webdav url and check "open as web folder".

    After that, users can drag and drop files into that folder, as if it where a common folder.

    You could even put perldav to god use :-)

    -- sevensven or nana korobi, ya oki
Re: Browser-based file uploads and deletions for a
by Anonymous Monk on Nov 18, 2001 at 06:44 UTC
    You probably should look at this