⬅ Back to Main README
The core module contains the main implementation of the BunnyNet Java client.
It provides the infrastructure required to interact with the Bunny Storage API, including HTTP communication, request models, region configuration, and storage clients.
The module includes support for both:
- Single-region storage
- Multi-region storage
Two storage clients are available inside this module.
| Client | Description |
|---|---|
SingleBunnyStorage |
Use when your application stores files in one storage zone and region |
MultiBunnyStorage |
Use when your application interacts with multiple storage zones or regions |
SingleBunnyNetConfig config =
new SingleBunnyNetConfig(
"API_KEY",
Region.LONDON_UK,
"storage-zone"
);SingleBunnyStorage storage =
SingleBunnyStorage.create(config);PutObjectRequest request =
new PutObjectRequest(
"images/photo.png",
contentType,
metadata,
inputStream
);
storage.uploadFile(request);GetObjectResponse response =
storage.downloadFile("images/photo.png");You can access the file stream from the response:
InputStream stream = response.inputStream();storage.deleteFile("images/photo.png");Use the multi client when your application needs to interact with multiple storage zones or regions.
MultiBunnyNetConfig config =
new MultiBunnyNetConfig("API_KEY");MultiBunnyStorage storage =
MultiBunnyStorage.create(config);storage.uploadFile(
request,
"storage-zone",
Region.LONDON_UK
);GetObjectResponse response =
storage.downloadFile(
"storage-zone",
"images/photo.png",
Region.LONDON_UK
);storage.deleteFile(
"storage-zone",
"images/photo.png",
Region.LONDON_UK
);com.range.bunnynet.core
│
├── http
│ └── BunnyHttpClient
│
├── model
│ ├── PutObjectRequest
│ ├── PutObjectResponse
│ └── GetObjectResponse
│
├── region
│ └── Region
│
├── exception
│ ├── BunnyException
│ ├── BunnyConnectionFailedException
│ ├── BunnyFileUploadFailedException
│ ├── BunnyFileDownloadFailedException
│ ├── BunnyFileDeleteFailedException
│ ├── BunnyInvalidCredentialsException
│ └── BunnyObjectNotFoundException
│
├── single
│ └── SingleBunnyStorage
│
└── multi
└── MultiBunnyStorage
The library internally uses:
BunnyHttpClient
Responsibilities:
- building HTTP requests
- attaching authentication headers
- streaming uploads and downloads
- handling Bunny Storage API responses
The client is implemented using OkHttp Java HttpClient (java.net.http).
All library exceptions extend:
BunnyException
Hierarchy:
BunnyException
├─ BunnyConnectionFailedException
├─ BunnyFileUploadFailedException
├─ BunnyFileDownloadFailedException
├─ BunnyFileDeleteFailedException
├─ BunnyInvalidCredentialsException
└─ BunnyObjectNotFoundException
Example usage:
try {
storage.downloadFile("file.png");
} catch (BunnyException e) {
// handle bunny storage error
}- Java 17+
This project is licensed under the Apache License 2.0.