PiBox.Plugins.Persistence.Smb 1.0.61

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.61                
NuGet\Install-Package PiBox.Plugins.Persistence.Smb -Version 1.0.61                
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.61" />                
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.61                
#r "nuget: PiBox.Plugins.Persistence.Smb, 1.0.61"                
#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.61

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

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 62 10/22/2024
1.0.66 80 10/15/2024
1.0.64 73 10/14/2024
1.0.61 88 10/1/2024
1.0.60 90 9/27/2024
1.0.54 109 4/30/2024
1.0.51 136 2/27/2024
1.0.49 108 2/27/2024
1.0.47 132 2/21/2024
1.0.45 122 2/20/2024
1.0.43 115 2/13/2024
1.0.41 120 2/13/2024
1.0.39 124 2/8/2024
1.0.38 110 2/8/2024
1.0.37 113 2/8/2024
1.0.35 104 2/2/2024