Store assets on a storage server


I’m currently hosting Cockpit on a VPS/Droplet (DigitalOcean) and the files that have been uploaded to Cockpit are making huge inbound traffic (transfer limit is 1TB/month). I want to upload all the static assets to a storage server (i don’t want to use any cloud solutions because of their costs, so the CloudStorage plugin is not an option).
Is it possible to somehow point the storage folder to another server?


Somebody help me, please!

Well, you already mentioned the CloudStorage plugin.

Having a look at its bootstrap.php it shows that the point of interest seems to be the cockpit.filestorages.init event.

This event is fired here cockpit/bootstrap.php at 568b0124352f6d27df359e8c19a70d2dd1961e87 · agentejo/cockpit · GitHub

It allows you to alter the $storages object (just like the CloudStorage plugin), which is then loaded into the FileStorage class.

I hope this helps a little.

Let us know how your adjustment turned out to hook up a custom server interface

Addition: the FileStorage class uses the PhpLeague Flysystem for the file system adapters. They have a whole list on adapters prepared, including FTP and SFTP, in case that is what your server needs ( SFTP Adapter - Flysystem )

Hey @abernh, thanks for your reply!

I’m not really familiar with PHP but will have a look on the things that you have mentioned.