PiBox.Plugins.Persistence.Smb 1.0.41

There is a newer version of this package available.
See the version list below for details.
dotnet add package PiBox.Plugins.Persistence.Smb --version 1.0.41                
NuGet\Install-Package PiBox.Plugins.Persistence.Smb -Version 1.0.41                
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="PiBox.Plugins.Persistence.Smb" Version="1.0.41" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PiBox.Plugins.Persistence.Smb --version 1.0.41                
#r "nuget: PiBox.Plugins.Persistence.Smb, 1.0.41"                
#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 PiBox.Plugins.Persistence.Smb as a Cake Addin
#addin nuget:?package=PiBox.Plugins.Persistence.Smb&version=1.0.41

// Install PiBox.Plugins.Persistence.Smb as a Cake Tool
#tool nuget:?package=PiBox.Plugins.Persistence.Smb&version=1.0.41                

PiBox.Plugins.Persistence.Smb

PiBox framework

PiBox.Plugins.Persistence.Smb is a plugin that allows other pibox components to do interact witha Smb compatible storage.

Installation

To install the nuget package follow these steps:

dotnet add package PiBox.Plugins.Persistence.Smb

or add as package reference to your .csproj

<PackageReference Include="PiBox.Plugins.Persistence.Smb" Version="" />

Appsettings.yml

Configure your appsettings.yml with these properties

smb:
  server: example.com
  domain: mydomain.com
  defaultShare: myshare
  driveMappings:
    - drive: 'J:'
      share: myshare
  shareMappings:
    - folder: myfolder
      share: myshare

Usage

public class ExampleService
{
    private readonly ISmbStorage _smbStorage;

    // retrieve the registered service ISmbStorage from the DI container via depentency injection
    public ExampleService(ISmbStorage smbStorage)
    {
        _smbStorage = smbStorage;
    }

    // ensure a file exist in the smb storage
    public async Task EnsurePathAsync()
    {
        await _fileStorage.EnsurePathAsync("folder/subfolder/", cancellationToken);
    }

    // delete a file from the smb storage
    public async Task DeleteIfExists()
    {
        await _fileStorage.DeleteIfExists("folder/myfile.txt", cancellationToken);
    }

    // write a byte array as file content to the smb storage
    public async Task WriteAsync()
    {
        await _fileStorage.WriteAsync("folder/myfile.txt", new byte[0], cancellationToken);
    }

    // write a string as file content to the smb storage
    public async Task WriteStringAsync()
    {
        await _fileStorage.WriteStringAsync("folder/myfile.txt", "hello world", cancellationToken);
    }

    // write a stream as file content to the smb storage
    public async Task WriteStreamAsync()
    {
        await _fileStorage.WriteStringAsync("folder/myfile.txt", new MemoryStream(), cancellationToken);
    }

    // read a file form smb storage and return content as string
    public async Task ReadStringAsync()
    {
        string content = await ReadStreamAsync("folder/myfile.txt", cancellationToken);
    }

    // read a file form smb storage and return content as byte array
    public async Task ReadBytesAsync()
    {
        bytes[] stream = await ReadStreamAsync("folder/myfile.txt", cancellationToken);
    }
}
Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.73 70 10/22/2024
1.0.66 86 10/15/2024
1.0.64 79 10/14/2024
1.0.61 94 10/1/2024
1.0.60 94 9/27/2024
1.0.54 113 4/30/2024
1.0.51 140 2/27/2024
1.0.49 112 2/27/2024
1.0.47 136 2/21/2024
1.0.45 126 2/20/2024
1.0.43 119 2/13/2024
1.0.41 124 2/13/2024
1.0.39 128 2/8/2024
1.0.38 114 2/8/2024
1.0.37 117 2/8/2024
1.0.35 110 2/2/2024