Blobject.Core 5.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package Blobject.Core --version 5.0.5                
NuGet\Install-Package Blobject.Core -Version 5.0.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Blobject.Core" Version="5.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Blobject.Core --version 5.0.5                
#r "nuget: Blobject.Core, 5.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Blobject.Core as a Cake Addin
#addin nuget:?package=Blobject.Core&version=5.0.5

// Install Blobject.Core as a Cake Tool
#tool nuget:?package=Blobject.Core&version=5.0.5                

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#.

NuGet Version NuGet

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 to Blobject
  • Added support for CIFS and NFS
  • Remove use of continuation tokens for disk
  • 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.AmazonS3;

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}
	);

AmazonS3BlobClient blobs = new AmazonS3BlobClient(settings); 

Getting Started - Azure

using Blobject.AzureBlob;

AzureBlobSettings settings = new AzureBlobSettings(
	accountName, 
	accessKey, 
	"https://[accountName].blob.core.windows.net/", 
	containerName);

AzureBlobClient blobs = new AzureBlobClient(settings); 

Getting Started - CIFS

using Blobject.CIFS;

CifsSettings settings = new CifsSettings(
	IPAddress.Parse("127.0.0.1"),
	username,
	password,
	sharename);

CifsBlobClient blobs = new CifsBlobClient(settings);

Getting Started - Disk

using Blobject.Disk;

DiskSettings settings = new DiskSettings("blobs"); 

DiskBlobClient blobs = new DiskBlobClient(settings);

Getting Started - NFS

using Blobject.NFS;

NfsSettings settings = new NfsSettings(
	IPAddress.Parse("127.0.0.1"),
	0, // user ID
	0, // group ID,
	sharename,
	NfsVersionEnum.V3 // V2, V3, or V4
	);

NfsBlobClient = new NfsBlobClient(settings);

Getting Started (Byte Arrays for Smaller Objects)

await blobs.WriteAsync("test", "text/plain", "This is some data");  // throws IOException
byte[] data = await blobs.GetAsync("test");                         // throws IOException
bool exists = await blobs.ExistsAsync("test");
await blobs.DeleteAsync("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.WriteAsync("key", "content-type", contentLength, fs);  // throws IOException
}

// Downloading to a stream
BlobData blob = await _Blobs.GetStreamAsync(key);
// read blob.ContentLength bytes from blob.Data

Metadata and Enumeration

// Get BLOB metadata
BlobMetadata md = await _Blobs.GetMetadataAsync("key");

// Enumerate BLOBs
EnumerationResult result = await _Blobs.EnumerateAsync();
// 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!

// instantiate two BLOB clients
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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last updated
5.0.8 918 8/27/2024
5.0.7 3,086 5/16/2024
5.0.6 125 4/30/2024
5.0.5 616 4/29/2024
5.0.4 121 4/28/2024
5.0.3 111 4/28/2024
5.0.1 103 4/26/2024
5.0.0 86 4/26/2024

Add support for CIFS and NFS.