Crates.io | files |
lib.rs | files |
version | 2.2.3 |
source | src |
created_at | 2021-04-11 03:52:46.519703 |
updated_at | 2021-05-30 07:59:52.565978 |
description | CDN Origin Server for Cloud Storage |
homepage | |
repository | https://github.com/apibillme/files |
max_upload_size | |
id | 381877 |
size | 136,901 |
The purpose of this service is to be your CDN Origin Server for Cloud Storage for any JSON client including JavaScript front-ends like React with fetch.
Files supports aws s3, vultr, wasabi, yandex, and digital ocean.
Files is built to be simple and blazing fast with JWT verification, bucket management, and object management.
To use this service you need to have a running broker server.
files:full
or granular permissions files:provider, files:get_object, files:put_object, files:delete_object, files:create_bucket, files:list_bucket, or files:delete_bucket
aws
, wasabi
, yandex
, vultr
, and do
Provider | Region |
---|---|
wasabi | wa-us-east-1 |
wasabi | wa-us-east-2 |
wasabi | wa-us-west-1 |
wasabi | wa-eu-central-1 |
aws | us-east-1 |
aws | us-east-2 |
aws | us-west-1 |
aws | us-west-2 |
aws | ca-central-1 |
aws | ap-south-1 |
aws | ap-northeast-1 |
aws | ap-northeast-2 |
aws | ap-northeast-3 |
aws | cn-north-1 |
aws | cn-northwest-1 |
aws | eu-north-1 |
aws | eu-central-1 |
aws | eu-west-1 |
aws | eu-west-2 |
aws | eu-west-3 |
aws | me-south-1 |
aws | sa-east-1 |
do | nyc3 |
do | ams3 |
do | spg1 |
do | fra1 |
vultr | ewr1 |
yandex | ru-central1 |
POST /provider
{
"name": "aws",
"access_key": "AKIAIOSFODNN7EXAMPLE",
"secret_key": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
}
will return: 200
or 500
or 400
or 401
GET /files/{region}/{bucket}/{object_path}
{
"object_path": "/test.pdf",
"region": "wa-us-east-1",
"bucket": "test"
}
will return: 200
or 500
or 400
or 401
200 - will return a file stream with the proper content-type
POST /get
{
"object_path": "/test.pdf",
"region": "wa-us-east-1",
"bucket": "test"
}
will return: 200
or 500
or 400
or 401
200 - will return a file stream with the proper content-type
POST /put
{
"object_path": "/test.pdf",
"region": "wa-us-east-1",
"bucket": "test",
"file": "dGhpc2lzYXN0cmluZw=="
}
file
is a base64 encoded binary file - this is doable with the FileReader class in the browserwill return: the provider's status code (e.g. 200
, 400
)
POST /del
{
"object_path": "/test.pdf",
"region": "wa-us-east-1",
"bucket": "test"
}
will return: the provider's status code (e.g. 204
, 409
)
POST /create_bucket
{
"region": "wa-us-east-1",
"bucket": "test"
}
will return: 200
with no body response or the provider's status code (e.g. 409
) and the provider's error
{
"error": "provider's response as an xml string"
}
POST /delete_bucket
{
"region": "wa-us-east-1",
"bucket": "test"
}
will return: the provider's status code (e.g. 204
, 409
)
POST /list_bucket
{
"region": "wa-us-east-1",
"bucket": "test",
"prefix": "/",
"delimiter": "/"
}
delimiter
is an optional fieldwill return: 200
, 400
, 500
, 401
200 - will return an array of objects
{
"objects": [{
"key": "/test.pdf",
"e_tag": "33a64df551425fcc55e4d42a148795d9f25f89d4",
"storage_class": "STANDARD",
"size": 100,
"last_modified": "2021-04-14T22:34:04.000Z"
}]
}
GET or HEAD /
will return: 200
cargo install files
origin
can be passed in as a flag - default *
port
can be passed in as a flag - default 9999
- can only be set for unsecure connectionssecure
flag for https can be true or false - default false
auto_cert
flag for an autorenewing LetsEncrypt SSL cert can be true or false - requires a resolvable domain - default true
key_path
flag when auto_cert
is false
to set the SSL key path for your own cert - default certs/private_key.pem
cert_path
flag when auto_cert
is false
to set the SSL cert path for your own cert - default certs/chain.pem
certs
flag is the storage path of LetsEncrypt certs - default certs
db
flag is the path where the embedded database will be saved - default db
domain
flag is the domain name (e.g. api.broker.com) of the domain you want to register with LetsEncrypt - must be fully resolvablebroker
flag is the broker domain/ip/port of the broker server - default http://localhost:8080
./files --secure="true" --domain="files.broker.com" --broker="https://broker.broker.com"
There is an example systemctl
service for Ubuntu called files.service
in the code