Home

Awesome

Cloud Storage Server

An open source, extensible, self-hosted cloud storage API. The base server implements a complete file system similar to Amazon Cloud Drive, B2 Cloud Storage, OpenDrive, and other providers. Just don't expect to build a scalable service with this software.

Cloud Storage Server pairs quite nicely with Cloud Backup and Cloud Storage Tools.

Donate Discord

Features

Uses

Getting Started

Download or clone the latest software release. If you do not have PHP installed, then download and install the command-line (CLI) version for your OS (e.g. 'apt install php-cli' on Debian/Ubuntu). Windows users try Portable Apache + PHP.

You'll also need to enable the SQLite and OpenSSL PHP modules for your PHP CLI version (e.g. 'apt install php-sqlite php-openssl' on Debian/Ubuntu, edit the 'php.ini' file on Windows).

From a command-line, run:

php install.php

The installer will ask a series of questions that will create the baseline server configuration. If extensions will be used that require "root" privileges (e.g. /scripts and /feeds), be sure to enter "root" for the user. When adding extensions or upgrading, re-run the installation command before starting the server to avoid problems. Skip the service installation step until you are ready to have the software run at boot.

Run the user management interface and add a user with access to the 'files' extension (grants access to the /files API):

php manage.php

Ready.  This is a command-line interface.  Enter 'help' to get a list of available commands.

>adduser yourusername
Host:  https://localhost:9892
API key:  abcdef12......34567890-1
>adduserext yourusername files
[Files Ext] Allow file download access (Y/N):  Y
[Files Ext] Allow folder write, file upload, trash access (Y/N):  Y
[Files Ext] Allow permanent folder and file delete access (Y/N):  Y
[Files Ext] Allow guest creation/deletion (Y/N):  Y
>exit

Be sure to copy the Host and API key somewhere. Depending on the configuration and setup, Host might not be correct. Adjust it accordingly.

To make sure the server works correctly, run it directly at first:

php server.php

Then connect to the server with a valid client SDK using the Host and API key from earlier.

The easiest client to get started with is to use Cloud Storage Tools.

Example usage using the included PHP SDK with the /files extension:

<?php
	// This code is not intended for production environments.
	// See the Cloud Storage Tools source code for better/more correct usage.
	require_once "sdks/php/sdk_cloud_storage_server_files.php";

	// Set this to
	$host = "https://localhost:9892";
	$apikey = "abcdef12......34567890-1";

	$css = new CloudStorageServerFiles();

	// Note that this is the wrong way to call this function.
	// The last two parameters are supposed to point to SSL certificate information.
	// See:  CloudStorageServer_APIBase::SetAccessInfo($host, $apikey, $cafile, $cert)
	$css->SetAccessInfo($host, $apikey, false, false);

	// Force-loads the server's SSL cert and assume it to be valid.
	$result = $css->GetSSLInfo();
	if (!$result["success"])
	{
		var_dump($result);

		exit();
	}

	// Get the server's timestamp and root folder ID.
	$result = $css->GetRootFolderID();
	if (!$result["success"])
	{
		var_dump($result);

		exit();
	}

var_dump($result);

	// Obtain an object ID via a path.
	$result = $css->GetObjectByPath("/");
	if (!$result["success"])
	{
		var_dump($result);

		exit();
	}

	$id = $result["body"]["object"]["id"];

	// Retrieve the folder list associated with an ID.
	$result = $css->GetFolderList($id);
	if (!$result["success"])
	{
		var_dump($result);

		exit();
	}

var_dump($result);

Once everything is good to go, re-run the installer to install the server as a system service:

php install.php

Nifty Extensions

Both of the /feeds and /scripts extensions are considered mostly obsolete. If you need them, consider using xcron instead, which accomplishes nearly all of the same tasks that /feeds and /scripts does but far more elegantly.

Got an idea for an extension that you would like to see included? Open an issue on the issue tracker. Due to Cloud Storage Server being a server product that is intended to be network-facing, all included extensions must pass rigorous CubicleSoft standards. Extensions must also be dual licensed under MIT/LGPL.

Extension: /files

The files extension implements the /files/v1 API. To try to keep this page relatively short, here is the list of available APIs, the input request method, and successful return values (always JSON output with the exceptions of 'download' and 'downloaddatabase'):

GET /files/v1/folder/list/ID

POST /files/v1/folder/create

GET /files/v1/trash/list

POST /files/v1/file/upload/ID

GET /files/v1/file/download/ID[/filename]

GET /files/v1/file/downloaddatabase[/filename]

GET /files/v1/object/bypath/...

GET /files/v1/object/byname/ID/NAME

GET /files/v1/object/byid/ID

POST /files/v1/object/copy

POST /files/v1/object/move

POST /files/v1/object/rename/ID

POST /files/v1/object/trash/ID

POST /files/v1/object/restore/ID

POST /files/v1/object/delete/ID

GET /files/v1/user/root

GET /files/v1/user/limits

GET /files/v1/guest/list

POST /files/v1/guest/create

POST /files/v1/guest/delete/ID