-
Notifications
You must be signed in to change notification settings - Fork 0
RedHolmsDev/mfs.redholms.dev
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Project of NOT user-side file server. Because it's not user-side, there's no easy api to be used in browser.
You're supposed to create your own frontend above this if you want.
This server supports different "apps", i.e. file systems that don't share files with each other.
Essentially this server serves multiple file servers at once.
Note there's really no concept of a real file system, so you don't need to create directories.
Really, you can use ANY string as a path.
This server can hold up to 1073741824 (1 billion) files in all apps.
When doing ALL REQUESTS to this server, Authorization header must be set to:
"<app-id> <secret-key>"
Secret key is arbitrary 64 characters long string.
If you pass invalid Authorization header, 403 status code is returned
To download a file, make GET request with wanted pathname
To upload a file, make PUT request with wanted pathname. Don't use multipart, just send content in the body
To delete a file, make DELETE request with wanted pathname
If you want to allow users to download/upload files, see API below
API
All API requests uses POST method.
All parameters are sent in request body and encoded with JSON.
Methods reponses with JSON:
If no error:
{ ok: true; result: ...; }
If method doesn't return anything, "result" field is not present
If error:
{ ok: false; code: string; info: string; }
Generic errors:
"internal_error" - Explains inself
"idiot" - You're doing meaningless things
"invalid_json" - Body is not a JSON
"invalid_json_property_type" - Some parameter is invalid
METHODS
/download
Open download link for users
Parameters:
{
pathname: string; // path to a file
lifetime: number; // lifetime of the link in seconds
userIp?: string; // if set, allow download only from this IP
}
Result:
{
link: string; // URL to download a file
}
Errors:
"file_not_found" - Explains itself
/upload
Open upload link for users. User must perform a POST request to this url using multipart/form-data
Parameters:
{
pathname: string; // destination path
lifetime: number; // lifetime of the link in seconds
userIp?: string; // if set, allow upload only from this IP
oneTime?: boolean; // close link after successful upload? defaults to true
maxFileSize?: number; // max file size in bytes to upload. defaults to 100 MiB
}
Result:
{
link: string; // URL to download a file
}
CONTROL METHODS
These methods can be called only by app 0 (i.e. control app). This app is set at server setup.
/control/newApp
Create a new app
Parameters:
{
name: string; // cannonical name
secretKey: string; // secret key to use
}
Result:
{
id: number; // id of created app
}
Errors:
"invalid_secret_key" - Secret key is not 64 characters long or contains forbidden characters
/control/deleteApp
Delete an app
Parameters:
{
id: number;
}
Errors:
"no_app" - Explains itself
About
File server
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published