DO Spaces

A Wrapper to interact with Digital Ocean Spaces.

Definition

Namespace: Tipi.Tools.Services

Assembly: Tipi.Tools.Services.dll

Package: Tipi.Tools.DoSpaces

This class lets you interact with the Digital Ocean Spaces API.

Copied!

                
    Dictionary<string> values = new Dictionary<string>();
    values.Add("AccessKey", "ACCESS_KEY");
    values.Add("SecretKey", "SECRET_KEY");
    values.Add("BucketName", "BUCKET_NAME");
    values.Add("Root", "ROOT");
    values.Add("EndpointUrl", "ENDPOINT_URL");
    values.Add("Endpoint", "ENDPOINT");

    S3BucketOptions options = new S3BucketOptions(); 
    DoSpaces = new DoSpaces(options);
                
            
Dependency Injection

You can implement this class with a .Net Core app by injecting it on your Program.cs file.

Copied!

                
    using Tipi.Tools.Payments.Config;
    ...
    var builder = WebApplication.CreateBuilder(args);
    ...
    // Inject the Payment Processor
    // It is good practice to inject your keys from the Secrets.json
    builder.Services.ConfigureDoSpaces("ACCESS_KEY", "SECRET_KEY", "BUCKET_NAME", 
    "ROOT", "ENDPOINT_URL", "ENDPOINT"); 
                
            
Controller Example

Here is an example of how to use the class in a controller.

Copied!

                
    using Tipi.Toolkit;
    ...
    public class  CheckoutController : Controller
    {
        // Define your private property
        private readonly IDoSpaces _dospaces;
        ...
        public CheckoutController(IDoSpaces dospaces)
        {
            _dospaces = dospaces;
        }
    }
                
            
Usage Example

Here is an example of the complete usage of the class.

Copied!

                
    // upload a new image
    var response = await _dospaces.UploadFileAsync("file", "folder");
                
            
Remarks

The DoSpaces class is a wrapper to communicate with Digital Ocean Spaces, this wrapper counts with all the necessary Methods to upload, update and delete a file

The class has a contructure that require you to pass one parameters, your private key, you can obtain the key from the Culqi Web Portal. This class can work with the .Net Framework Dependency Injection, by providing methods to work in that way. All of the Method calls can be awaited and are thread safe

Constructors

Create an instance of DoSpaces class, takin as parameter a new object of type S3BucketOptions

Related Classes

Class used as parameter in order to initialize the DoSpaces class.