Skip to content

DubZero/AspNetCore.Yandex.ObjectStorage

Repository files navigation

AspNetCore.Yandex.ObjectStorage

.Net Core library for Yandex Object Storage S3 API (https://cloud.yandex.ru/docs/storage/s3/api-ref).

Nuget Package - AspNetCore.Yandex.ObjectStorage

How to use

To inject service user extension method AddYandexObjectStorage to IServiceCollection

services.AddYandexObjectStorage(options =>
{
  options.BucketName = "bucketName";
  options.AccessKey = "your-access-key";
  options.SecretKey = "your-secret-key";
});

OR

Can load options from IConfiguratiuonRoot as: services.AddYandexObjectStorage(Configuration); by default, it reads a section with the name YandexObjectStorage, for example, the section in appsettings.json below:

"YandexObjectStorage":
{
    "Bucket" : "your-bucket",
    "AccessKey" : "your-access-key",
    "SecretKey" : "your-secret-key",
    "Protocol" : "https",
    "Location" : "us-east-1"
}

Options is a YandexStorageOptions class. It provides access to setup next properties:

string Protocol - by default -> "https"
string BucketName
string Location - by default -> "us-east-1"
string Endpoint - by default -> "storage.yandexcloud.net"
string AccessKey
string SecretKey

Usage examples

S3ObjectPutResponse response = await _objectStoreService.ObjectService.PutAsync(byteArr, fileName);
S3ObjectDeleteResponse response = await _objectStoreService.ObjectService.DeleteAsync(filename);

Get can return as Stream or ByteArray

// result is FluentResults wrapped content of result
var result = await _objectStoreService.ObjectService.GetAsync(fileName);
if(result.IsSuccess) 
{
   byte[] byteArr = await result.ReadAsByteArrayAsync();
   Stream stream = await result.ReadAsStreamAsync();
}

if(result.IsFailed)
{
   var error = await result.ReadErrorAsync();
}

List of implemented API methods

Object service

Method Description Status
upload Uploads an object to Object Storage ✅ implemented
get Retrieves an object from Object Storage ✅ implemented
delete Deletes an object ✅ implemented
deleteMultipleObjects Deletes objects based on a list ✅ implemented
options Checks whether a CORS request to an object can be made ✅ implemented
selectObjectContent Filters and returns the contents of an object based on an SQL query ✅ implemented
copy Copies an object stored in Object Storage ❌ not implemented
getObjectMeta Retrieves object metadata ❌ not implemented

Bucket Service

Method Description Status
create Creates a bucket ✅ implemented
getMeta Returns the bucket's metadata or an error ✅ implemented
listObjects Returns a list of bucket objects. Pagination is used for output ✅ implemented
listBuckets Returns a list of buckets available to the user ✅ implemented
deleteBucket Deletes an empty bucket. If the bucket isn't empty, first delete all the objects inside the bucket ✅ implemented
getBucketEncryption Returns information about bucket encryption. For more information about bucket encryption ❌ not implemented
putBucketEncryption Adds encryption to the bucket. By default, the objects added to the bucket are encrypted with the specified KMS key ❌ not implemented
deleteBucketEncryption Removes encryption from the bucket. For more information about bucket encryption ❌ not implemented
putBucketVersioning Enables or pauses versioning of the bucket ❌ not implemented
getBucketVersioning Returns the versioning status ❌ not implemented
putBucketLogging Enables and disables logging of actions with the bucket ❌ not implemented
getBucketLogging Returns settings for logging actions with the bucket ❌ not implemented
listObjectVersions Returns metadata for all versions of objects in the bucket ❌ not implemented

Multipart upload service

Method Description Status
startUpload Starts multipart upload ❌ not implemented
uploadPart Uploads a part of an object ❌ not implemented
copyPart Copies part of an object ❌ not implemented
listParts Displays a list of uploaded parts ❌ not implemented
abortUpload Aborts multipart upload ❌ not implemented
completeUpload Completes multipart upload ❌ not implemented
listUploads Returns a list of incomplete uploads ❌ not implemented

Static Website Hosting service ❌ - not implemented

CORS service ❌ - not implemented

Lifecycles service ❌ - not implemented

ACL service ❌ - not implemented

Bucket Policy service ❌ - not implemented

About

.NET Client for Yandex.Cloud S3 API (Object Storage)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages