Densaugeo / uploadserver

Python's http.server extended to include a file upload page

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: Option for UUID-based filename

neruthes opened this issue · comments

Hello developers, I have found this software helpful, and hope that my needs may perhaps fit into your roadmap.

I would like to have an option for automatically renaming incoming files to UUID-based filenames.
This comes with some advantages:

  • Prevent filename collisions.
  • Erase potential sensitive info in the original filename.

Specifically...

  • --uuid: Enable UUID-based file naming, which converts example.tar.xz to c09f51d8-aeac-4d0f-9850-dff741756e09.tar.xz.
  • --uuid-bare: Similar to --uuid, but converts example.tar.xz to c09f51d8-aeac-4d0f-9850-dff741756e09.

If this feature is to be introduced, I would also like to recommend a few mini-features to come along with it:

  • Provide a Final-Full-Path response header.
  • In the /upload form page, generate an anchor with href set to the HTTP full path of the (renamed) file after successful upload.

Hello!

As of version 4, names that collide with existing file are renamed by default (unless --allow-replace is selected). If you see files being overwritten without renaming, please report a bug.

Regarding UUIDs, this sounds like a fairly specific use case (other people will likely use differing naming schemes, even if they're using UUIDs too). I'm not inclined to include this, unless I hear interest from more people. You should still be able to get the behaviour you're looking for pretty easily by customizing the auto_rename() function.

I'd be open to some minor refactoring if it helps make customization easier, but I'd like to keep the list of command line options short.

Thanks for your reply.

I get your point on the simplicity of both functionalities and CLI arguments; a very KISS attitude. I like KISS.

It inspired me that combining this software with a shell script will achieve the similar objective.

Start an uploadserver instance which writes files to /tmp/inbox, where very file inside will be moved to /var/www/uploads (served by another HTTP file server, e.g. Nginx) by a daemon script.

Clever! Glad to hear you found a solution.