The official .NET library used for interacting with the BunnyCDN Storage API.
The storage library is very simple to use. First, create the basic BunnyCDNStorage object with the authentication details. It's the basic object for interaction with the API.
var bunnyCDNStorage = new BunnyCDNStorage("storagezonename", "MyAccessKey", "de");
The BunnyCDNStorage constructor takes the following parameters:
Uploading supports either loading from a stream or reading directly from a local file path. If the path to the object does not exist yet, it will be automatically created.
Uploading from a stream
await bunnyCDNStorage.UploadAsync(stream, "/storagezonename/helloworld.txt");
Uploading a local file
await bunnyCDNStorage.UploadAsync("local/file/path/helloworld.txt", "/storagezonename/helloworld.txt");
Uploading with checksum verification
# Providing the hash
await bunnyCDNStorage.UploadAsync(stream, "/storagezonename/helloworld.txt", "d04b98f48e8f8bcc15c6ae5ac050801cd6dcfd428fb5f9e65c4e16e7807340fa");
await bunnyCDNStorage.UploadAsync("/local/path/to/file.txt", "/storagezonename/helloworld.txt", "d04b98f48e8f8bcc15c6ae5ac050801cd6dcfd428fb5f9e65c4e16e7807340fa");
# Auto generating the hash
await bunnyCDNStorage.UploadAsync(stream, "/storagezonename/helloworld.txt", true);
await bunnyCDNStorage.UploadAsync("/local/path/to/file.txt", "/storagezonename/helloworld.txt", true);
# Provide hash which will be auto-generated if format is invalid
await bunnyCDNStorage.UploadAsync(stream, "/storagezonename/helloworld.txt", true, "d04b98f48e8f8bcc15c6ae5ac050801cd6dcfd428fb5f9e65c4e16e7807340fa");
await bunnyCDNStorage.UploadAsync("/local/path/to/file.txt", "/storagezonename/helloworld.txt", true, "d04b98f48e8f8bcc15c6ae5ac050801cd6dcfd428fb5f9e65c4e16e7807340fa");
await bunnyCDNStorage.UploadAsync(stream, "/storagezonename/helloworld.txt", true, "invalidtobereplaced");
await bunnyCDNStorage.UploadAsync("/local/path/to/file.txt", "/storagezonename/helloworld.txt", true, "invalidtobereplaced");
Get a list of of all objects on the given path. Returns a List
var objects = await bunnyCDNStorage.GetStorageObjectsAsync("/storagezonename/");
The StorageObject contains the following properties:
Downloading supports either loading into a stream or saving directly to a local file.
Download as a stream
await bunnyCDNStorage.DownloadObjectAsStreamAsync("/storagezonename/helloworld.txt");
Download as a file
await bunnyCDNStorage.DownloadObjectAsync("/storagezonename/helloworld.txt", "local/file/path/helloworld.txt");
Deleting supports both files and directories. If the target object is a directory, the directory content will also be deleted.
await bunnyCDNStorage.DeleteObjectAsync("/storagezonename/helloworld.txt");