NueMedia
Nues self-improvement and development



<< Back

Hosting your own temporary files

Posted: Wed, 04 May 2022 12:25
Last edited: Mon, 09 May 2022 12:13

Tags: self-hosting software efficiency

In my quest to get more independent of big company services I like to create small programs that can acomplish simple tasks for me. So far I have self hosted videos, website, e-mail and chat. Sharing temporary files with people I usually do using Discord. You just drag and drop a file into discord and you have a forever stored copy of that file in the cloud. But as with everything you upload to some place, that file is no longer yours.

I spent two hours yesterday creating a very simple wsgi python program. All it does is present you with a file selector and a submit button. When you submit the file it prints the link to the file below. the service

To host it I just have an nginx location that proxy pass the request to the application. The application itself is running inside a screen session. $ screen -S file-upload

location /upload {
client_max_body_size 50M;
proxy_pass http://127.0.0.1:8000;
}

Lastly, because these files are temporary they also need to be removed. This is also very easy to do. A single line in your crontab can acomplish this.

0 0 * * * find /storage/tempfiles/* -mtime +7 --exec rm {} ;

This line will look for files at midnight every day and delete any file that is older than seven days. My files are stored under /storage/tempfiles so you need to change this to where you store your files.

If you want to install something like this yourself you can have a look at my code in GitHub.