Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion

Temp file transfer
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Temp file transfer

GiulioGiulio Member
edited September 2016 in General

Hi,
yesterday i noticed that it happens a lot that i have to transfer non confidential files to friends or servers and I always find it slow to do it.

So, this morning, with ~60 lines of python, based on flask and redis i built a simple service easily usable from command line.

Basically files can be uploaded with a PUT request to the domain index. Since the service is free from ads/tracking bad stuff, and the intended use is temporary the maximum storage of a file is 3 days.

curl --upload-file <localfile> https://files.re/ #Upload with default TTL (24 hours)
curl --upload-file <localfile> https://files.re/160/ # Upload with 160 seconds of TTL
curl --upload-file <localfile> https://files.re/2d3h5s/ # Upload with 2 days, 3 hours and 2 seconds of TTL
curl --upload-file <localfile> https://files.re/2d3h5s/<filename> # Upload with 2 days, 3 hours and 2 seconds of TTL and <filename> as filename

curl https://files.re/ttl/<id> # Get remaining seconds

curl -O https://files.re/<id> # Download with original filename
curl -O https://files.re/<id>/<filename> # Download with <filename>

Please not that the trailing '/' is essential when specifying the TTL: otherwise the TTL will be interpred as the filename.

Source is coming, i'm just tidying it up before publishing.

Redis is used for storing a simple random_string->filename TTL association. However, no cron is needed to clean up the expired files because, for those who didn't know, redis has a 'notifications' feature with will send notifications about keyspace changes to a listener. It is not guaranteed that a notification will be sent instantly when a key expire, but it won't take much since redis checks in the background incrementally or send the notification instantly when something try to access the expired key. Of course other events can be notified too.

I'm sure services like this already existed, but i wanted my own.

Comments

Sign In or Register to comment.