Akasha
![]()
Akasha is a service that provides file access and sharing capabilities across multiple protocols such as SFTP and other over HTTP-based APIs. The main goal of Akasha is to offer a unified platform for managing and sharing files securely and efficiently. It is targeted at developers and tech-savvy users that do not need fancy pancy web interfaces, but rather a reliable and easy-to-use backend service.
Akasha is built with security and privacy in mind. Reading and writing files can be protected behind a token-based authentication system, ensuring that only authorized users or systems can access the data.
It also supports multiple storage backends, allowing you to define multiple so-called data sources. All this is packaged in lightweight Java application with small memory footprint with also super-lightweight jar file size of ~150KB.
Source Code — Documentation — Akasha-API-Kirara Maven Central
Built using Sigewine — Jean — Ganyu — Kirara
Features
- Serving files from multiple data sources over HTTP
Define multiple data sources with different storage backends to be served over HTTP.
- Authentication over tokens
Allows you to secure access to your files using token-based authentication.
- Intelligent MIME/Content-Type detection
Automatically detects and sets the correct MIME type for served files based on their file extensions.
- Respects
Acceptheader Serves files in the format requested by the client, if supported (e.g., HTML, JSON or plain text).
- Proper
InputStreamhandling Efficiently manages file streams to optimize performance and resource usage. This means that large files can be served without consuming excessive memory or disk space.
- Careful path traversal protection
Ensures that file access is restricted to the defined data sources, preventing unauthorized access.
- Simple API
Provides a straightforward read/write API for file operations.
- Lightweight
Small memory footprint without confusing installation or configuration requirements.
- Prometheus metrics
Exposes Prometheus-compatible metrics for monitoring and observability.
Installation
Download the latest Akasha jar file from the GitHub releases
Download your favorite Java Runtime Environment (JRE) if you don't have one already. Akasha requires at least Java 21. Temurin Adoptium is tested and works well, but any Java 21+ runtime should work.
Run Akasha with the following command:
java -jar akasha-x.y.z-all.jarWait till the dependencies are downloaded. After that, Akasha will terminate automatically in order for JVM to load them properly.
Repeat the 3rd step to generate default configuration files.
Configure Akasha by editing configuration files in the
configs/directory.Try accessing Akasha at
http://localhost:7000/data-source/{data-source}/{file-path}
Usage
After running Akasha, you can access files from your configured data sources using the following URL pattern: https://{hostname}/data-source/{data-source-name}/{file-path}
If a data source path allows write access, you may also upload files using HTTP PUT requests to the same URL. This requires you to specify attachment called file in the multipart/form-data body of the request.
API Endpoints
GET /data-source/{name}/{file-path}
Retrieves the specified file from the given data source.
The response will include the file's content in bytes. Respects the Accept header for response format. If the file is not found or access is denied, appropriate HTTP status codes will be returned.
Data in raw bytes.
The Content-Type header will depend on the file being served (fallbacks to application/octet-stream if unknown).
Status code 400 is used when the request is malformed, or you try to access a path that is not allowed.
PUT /data-source/{name}/{file-path}
Uploads a file to the specified path in the given data source.
Accepts application/octet-stream with the file content in the request body.
The response will indicate success or failure of the upload operation.
Status code 400 is used when the request is malformed, or you try to access a path that is not allowed.
DELETE /data-source/{name}/{file-path}
Deletes file or directory at the specified path in the given data source. Directories must be empty before deletion.
The response will indicate success or failure of the delete operation.
Status code 400 is used when the request is malformed, or you try to access a path that is not allowed.
POST /data-source/{name}/{file-path}
Allows you to manage the specified file in the given data source. The request body includes ActionParametersDTO determining the action to perform. This action type then determines the response content.
Action Type | Response Content | Description |
|---|---|---|
|
| Retrieves metadata about the specified file. |
|
| Lists files in the specified directory. |
|
| Recursively lists files in the specified directory and its subdirectories. |
The response will indicate success or failure of the manage operation.
Configuration
data_sources.json
Allows you to configure multiple data sources with different storage backends.
validateWritePermissionEntriesHaveTokenWhen true, Akasha will terminate if any write permission entry does not specify at least one token.
SFTP Data Source
This configuration defines an SFTP data source named "my-sftp-storage" that connects to an SFTP server at sftp.example.com on port 22 using the provided username and password. It also specifies permission entries for three paths:
The
public/path is read-only and does not require any tokens for access.The
private/path allows write access but requires the tokenmy-secret-tokenfor authentication.The
metadata/data.jsonfile is read-only and requires the tokensecret-datafor access.
file_cache.json
Configure file caching options to improve performance.
enabledEnables or disables file caching.
resetTtlOnAccessIf true, resets the TTL of cached files upon access.
directorySpecifies the directory where cached files are stored.
ttlSecondsSets the time-to-live for cached files in seconds.
maxSizePerFileBytesDefines the maximum size for individual cached files in bytes.
maxTotalSizeBytesSets the maximum total size for all cached files in bytes. No new files will be cached if this limit would be reached when adding the new file.
httpCacheMaxAgeSecondsSets the
Cache-Control: max-ageheader value for HTTP responses in seconds. This minimizes repeated requests from clients.
javalin.json
Configure Javalin server options.
portSpecifies the port on which the HTTP server listens for incoming requests.
maxRequestSizeBytesSets the maximum allowed size for incoming HTTP requests in bytes. Requests exceeding this size will be rejected with a
413 Payload Too Largestatus code.
prometheus.json
Configure Prometheus metrics options.
enabledEnables or disables Prometheus
/metricsendpoint.jvmMetricsEnabledIf true, JVM metrics such as memory usage and garbage collection stats are included in the Prometheus metrics.
bearerTokenIf set, requires this bearer token for accessing the
/metricsendpoint.
Akasha API Kirara
Akasha comes with a Java API wrapper built on top of Kirara called Akasha API Kirara. This library simplifies interaction with Akasha from Java applications.
Installation
Akasha API Kirara is available on Maven Central.
Usage
Here's a simple example of how to use Akasha API Kirara to read and write files from/to an Akasha server: