Blobject.Core
5.0.4
See the version list below for details.
dotnet add package Blobject.Core --version 5.0.4
NuGet\Install-Package Blobject.Core -Version 5.0.4
<PackageReference Include="Blobject.Core" Version="5.0.4" />
paket add Blobject.Core --version 5.0.4
#r "nuget: Blobject.Core, 5.0.4"
// Install Blobject.Core as a Cake Addin #addin nuget:?package=Blobject.Core&version=5.0.4 // Install Blobject.Core as a Cake Tool #tool nuget:?package=Blobject.Core&version=5.0.4
Blobject
Blobject (formerly BlobHelper) is a common, consistent storage interface for Microsoft Azure, Amazon S3, S3 compatible storage (i.e. Minio, Less3, View), CIFS (Windows file shares), NFS (Linux and UNIX file shares), and local filesystem written in C#.
Help, Feedback, Contribute
If you have any issues or feedback, please file an issue here in Github. We'd love to have you help by contributing code for new features, optimization to the existing codebase, ideas for future releases, or fixes!
Overview
This project was built to provide a simple interface over external storage to help support projects that need to work with potentially multiple storage providers. It is by no means a comprehensive interface, rather, it supports core methods for creation, retrieval, deletion, metadata, and enumeration.
Contributors
- @phpfui for adding the original code for BLOB copy functionality
- @Revazashvili for fixes related to byte array instantiation, Azure, and refactoring
- @courtzzz for keeping the region list updated
Dependencies
Though this library is MIT licensed, it is dependent upon other libraries, some of which carry a different license. Each of these libraries are included by reference, that is, none of their code has been modified.
Package | URL | License |
---|---|---|
AWSSDK.S3 | https://github.com/aws/aws-sdk-net | Apache 2.0 |
Azure.Storage.Blobs | https://github.com/Azure/azure-sdk-for-net | MIT |
EzSmb | https://github.com/ume05rw/EzSmb | LGPL-3.0 |
SMBLibrary | https://github.com/TalAloni/SMBLibrary | LGPL-3.0 |
NFS-Client | https://github.com/SonnyX/NFS-Client | Unknown, public |
Nekodrive | https://github.com/nekoni/nekodrive | Unknown, public |
S3Lite | https://github.com/jchristn/S3Lite | MIT |
New in v5.0.x
- Rename from
BlobHelper
toBlobject
- Added support for CIFS and NFS
- Refactor
Example Project
Refer to the Test
project for exercising the library.
Getting Started - AWS S3
using Blobject;
AwsSettings settings = new AwsSettings(
accessKey,
secretKey,
AwsRegion.USWest1,
bucket);
BlobClient blobs = new BlobClient(settings);
Getting Started - AWS S3 Compatible Storage (Minio, Less3, etc)
using Blobject;
AwsSettings settings = new AwsSettings(
endpoint, // http://localhost:8000/
true, // enable or disable SSL
accessKey,
secretKey,
AwsRegion.USWest1,
bucket,
baseUrl // i.e. http://localhost:8000/{bucket}/{key}
);
BlobClient blobs = new BlobClient(settings);
Getting Started - Azure
using Blobject;
AzureSettings settings = new AzureSettings(
accountName,
accessKey,
"https://[accountName].blob.core.windows.net/",
containerName);
BlobClient blobs = new BlobClient(settings);
Getting Started - Disk
using Blobject;
DiskSettings settings = new DiskSettings("blobs");
BlobClient blobs = new BlobClient(settings);
Getting Started (Byte Arrays for Smaller Objects)
await blobs.Write("test", "text/plain", "This is some data"); // throws IOException
byte[] data = await blobs.Get("test"); // throws IOException
bool exists = await blobs.Exists("test");
await blobs.Delete("test");
Getting Started (Streams for Larger Objects)
// Writing a file using a stream
FileInfo fi = new FileInfo(inputFile);
long contentLength = fi.Length;
using (FileStream fs = new FileStream(inputFile, FileMode.Open))
{
await _Blobs.Write("key", "content-type", contentLength, fs); // throws IOException
}
// Downloading to a stream
BlobData blob = await _Blobs.GetStream(key);
// read blob.ContentLength bytes from blob.Data
Metadata and Enumeration
// Get BLOB metadata
BlobMetadata md = await _Blobs.GetMetadata("key");
// Enumerate BLOBs
EnumerationResult result = await _Blobs.Enumerate();
// list of BlobMetadata contained in result.Blobs
// continuation token in result.NextContinuationToken
Copying BLOBs from Repository to Repository
If you have multiple storage repositories and wish to move BLOBs from one repository to another, use the BlobCopy
class (refer to the Test.Copy
project for a full working example).
Thanks to @phpfui for contributing code and the idea for this enhancement!
Blobs from = new Blobs(new DiskSettings("./disk1/")); // assume some files are here
Blobs to = new Blobs(new DiskSettings("./disk2/"));
BlobCopy copy = new BlobCopy(from, to);
CopyStatistics stats = copy.Start();
/*
{
"Success": true,
"Time": {
"Start": "2021-12-22T18:44:42.9098249Z",
"End": "2021-12-22T18:44:42.9379215Z",
"TotalMs": 28.1
},
"ContinuationTokens": 0,
"BlobsEnumerated": 12,
"BytesEnumerated": 1371041,
"BlobsRead": 12,
"BytesRead": 1371041,
"BlobsWritten": 12,
"BytesWritten": 1371041,
"Keys": [
"filename.txt",
...
]
}
*/
Version History
Refer to CHANGELOG.md for version history.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.CSharp (>= 4.7.0)
- System.Text.Json (>= 8.0.3)
- Timestamps (>= 1.0.8)
-
net6.0
- Microsoft.CSharp (>= 4.7.0)
- System.Text.Json (>= 8.0.3)
- Timestamps (>= 1.0.8)
-
net7.0
- Microsoft.CSharp (>= 4.7.0)
- System.Text.Json (>= 8.0.3)
- Timestamps (>= 1.0.8)
-
net8.0
- Microsoft.CSharp (>= 4.7.0)
- System.Text.Json (>= 8.0.3)
- Timestamps (>= 1.0.8)
NuGet packages (7)
Showing the top 5 NuGet packages that depend on Blobject.Core:
Package | Downloads |
---|---|
View.Models
View.io is currently in BETA. Database models and supporting classes for View.io services. |
|
Blobject.AzureBlob
BLOB storage client for Microsoft Azure BLOB. Refer to other Blobject packages for other storage repository types. |
|
Blobject.AmazonS3
BLOB storage client for Amazon S3 (including compatible storage e.g. Minio, Less3, Ceph, View). Refer to other Blobject packages for other storage repository types. |
|
Blobject.CIFS
BLOB storage client for CIFS and SMB file servers, e.g. Windows and SAMBA. Refer to other Blobject packages for other storage repository types. |
|
Blobject.Disk
BLOB storage client for local filesystem and pre-established mount points. Refer to other Blobject packages for other storage repository types. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Add support for CIFS and NFS.