Giter VIP home page Giter VIP logo

minio-dotnet's Introduction

MinIO Client SDK for .NET

MinIO Client SDK provides higher level APIs for MinIO and Amazon S3 compatible cloud storage services.For a complete list of APIs and examples, please take a look at the Dotnet Client API Reference.This document assumes that you have a working VisualStudio development environment.

Slack Github Actions Nuget GitHub tag (with filter)

Install from NuGet

To install MinIO .NET package, run the following command in Nuget Package Manager Console.

PM> Install-Package Minio

MinIO Client Example for ASP.NET

When using AddMinio to add Minio to your ServiceCollection, Minio will also use any custom Logging providers you've added, like Serilog to output traces when enabled.

using Minio;
using Minio.DataModel.Args;

public static class Program
{
    var endpoint = "play.min.io";
    var accessKey = "minioadmin";
    var secretKey = "minioadmin";

    public static void Main(string[] args)
    {
        var builder = WebApplication.CreateBuilder();

        // Add Minio using the default endpoint
        builder.Services.AddMinio(accessKey, secretKey);

        // Add Minio using the custom endpoint and configure additional settings for default MinioClient initialization
        builder.Services.AddMinio(configureClient => configureClient
            .WithEndpoint(endpoint)
            .WithCredentials(accessKey, secretKey)
	    .Build());

        // NOTE: SSL and Build are called by the build-in services already.

        var app = builder.Build();
        app.Run();
    }
}

[ApiController]
public class ExampleController : ControllerBase
{
    private readonly IMinioClient minioClient;

    public ExampleController(IMinioClient minioClient)
    {
        this.minioClient = minioClient;
    }

    [HttpGet]
    [ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
    public async Task<IActionResult> GetUrl(string bucketID)
    {
        return Ok(await minioClient.PresignedGetObjectAsync(new PresignedGetObjectArgs()
                .WithBucket(bucketID))
            .ConfigureAwait(false));
    }
}

[ApiController]
public class ExampleFactoryController : ControllerBase
{
    private readonly IMinioClientFactory minioClientFactory;

    public ExampleFactoryController(IMinioClientFactory minioClientFactory)
    {
        this.minioClientFactory = minioClientFactory;
    }

    [HttpGet]
    [ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
    public async Task<IActionResult> GetUrl(string bucketID)
    {
        var minioClient = minioClientFactory.CreateClient(); //Has optional argument to configure specifics

        return Ok(await minioClient.PresignedGetObjectAsync(new PresignedGetObjectArgs()
                .WithBucket(bucketID))
            .ConfigureAwait(false));
    }
}

MinIO Client Example

To connect to an Amazon S3 compatible cloud storage service, you need the following information

Variable name Description
endpoint <Domain-name> or <ip:port> of your object storage
accessKey User ID that uniquely identifies your account
secretKey Password to your account
secure boolean value to enable/disable HTTPS support (default=true)

The following examples uses a freely hosted public MinIO service "play.min.io" for development purposes.

using Minio;

var endpoint = "play.min.io";
var accessKey = "minioadmin";
var secretKey = "minioadmin";
var secure = true;
// Initialize the client with access credentials.
private static IMinioClient minio = new MinioClient()
                                    .WithEndpoint(endpoint)
                                    .WithCredentials(accessKey, secretKey)
                                    .WithSSL(secure)
                                    .Build();

// Create an async task for listing buckets.
var getListBucketsTask = await minio.ListBucketsAsync().ConfigureAwait(false);

// Iterate over the list of buckets.
foreach (var bucket in getListBucketsTask.Result.Buckets)
{
    Console.WriteLine(bucket.Name + " " + bucket.CreationDateDateTime);
}

Complete File Uploader Example

This example program connects to an object storage server, creates a bucket and uploads a file to the bucket. To run the following example, click on [Link] and start the project

using System;
using Minio;
using Minio.Exceptions;
using Minio.DataModel;
using Minio.Credentials;
using Minio.DataModel.Args;
using System.Threading.Tasks;

namespace FileUploader
{
    class FileUpload
    {
        static void Main(string[] args)
        {
            var endpoint  = "play.min.io";
            var accessKey = "minioadmin";
            var secretKey = "minioadmin";
            try
            {
                var minio = new MinioClient()
                                    .WithEndpoint(endpoint)
                                    .WithCredentials(accessKey, secretKey)
                                    .WithSSL()
                                    .Build();
                FileUpload.Run(minio).Wait();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadLine();
        }

        // File uploader task.
        private async static Task Run(IMinioClient minio)
        {
            var bucketName = "mymusic";
            var location   = "us-east-1";
            var objectName = "golden-oldies.zip";
            var filePath = "C:\\Users\\username\\Downloads\\golden_oldies.mp3";
            var contentType = "application/zip";

            try
            {
                // Make a bucket on the server, if not already present.
                var beArgs = new BucketExistsArgs()
                    .WithBucket(bucketName);
                bool found = await minio.BucketExistsAsync(beArgs).ConfigureAwait(false);
                if (!found)
                {
                    var mbArgs = new MakeBucketArgs()
                        .WithBucket(bucketName);
                    await minio.MakeBucketAsync(mbArgs).ConfigureAwait(false);
                }
                // Upload a file to bucket.
                var putObjectArgs = new PutObjectArgs()
                    .WithBucket(bucketName)
                    .WithObject(objectName)
                    .WithFileName(filePath)
                    .WithContentType(contentType);
                await minio.PutObjectAsync(putObjectArgs).ConfigureAwait(false);
                Console.WriteLine("Successfully uploaded " + objectName );
            }
            catch (MinioException e)
            {
                Console.WriteLine("File Upload Error: {0}", e.Message);
            }
        }
    }
}

Running MinIO Client Examples

On Windows

  • Clone this repository and open the Minio.Sln in Visual Studio 2017.

  • Enter your credentials and bucket name, object name etc. in Minio.Examples/Program.cs

  • Uncomment the example test cases such as below in Program.cs to run an example.

  //Cases.MakeBucket.Run(minioClient, bucketName).Wait();
  • Run the Minio.Client.Examples project from Visual Studio

On Linux

Setting .NET SDK on Linux (Ubuntu 22.04)

NOTE: minio-dotnet requires .NET 6.x SDK to build on Linux.
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0

Running Minio.Examples

  • Clone this project.
$ git clone https://github.com/minio/minio-dotnet && cd minio-dotnet
  • Enter your credentials and bucket name, object name etc. in Minio.Examples/Program.cs Uncomment the example test cases such as below in Program.cs to run an example.
  //Cases.MakeBucket.Run(minioClient, bucketName).Wait();
dotnet build --configuration Release --no-restore
dotnet pack ./Minio/Minio.csproj --no-build --configuration Release --output ./artifacts
dotnet test ./Minio.Tests/Minio.Tests.csproj

Bucket Operations

Bucket policy Operations

Bucket notification Operations

File Object Operations

Object Operations

Presigned Operations

Client Custom Settings

Explore Further

minio-dotnet's People

Contributors

adamhodgson avatar bigustad avatar dependabot[bot] avatar djwfyi avatar ebozduman avatar fnandes avatar harshavardhana avatar ig-sinicyn avatar kannappanr avatar kerams avatar koolhead17 avatar krishnasrinivas avatar krisis avatar mardipp avatar martijn00 avatar minio-trusted avatar mruslan97 avatar ngbrown avatar nitisht avatar no0dles avatar olsh avatar pbolduc avatar pjuarezd avatar poornas avatar praveenrajmani avatar purplestviper avatar tinohager avatar tvdias avatar vadmeste avatar wolfspiritm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minio-dotnet's Issues

Fix files not found errors

                Tool /usr/lib/mono/4.5/mcs.exe execution started with arguments: /noconfig /debug:pdbonly /optimize+ /out:obj/Release/Minio.Client.dll Acl.cs Errors/ConnectionException.cs Errors/AccessDeniedException.cs Errors/MethodNotAllowedException.cs Errors/ForbiddenException.cs Errors/InternalServerException.cs Errors/RedirectionException.cs Errors/ObjectNotFoundException.cs Errors/ObjectExistsException.cs Errors/MaxBucketsReachedException.cs Errors/InvalidRangeException.cs Errors/InvalidKeyNameException.cs Errors/InvalidBucketNameException.cs Errors/InvalidAclNameException.cs Errors/InternalClientException.cs Errors/BucketNotFoundException.cs Errors/BucketExistsException.cs Errors/DataSizeMismatchException.cs ItemEnumerable.cs Regions.cs Errors/ClientException.cs Xml/AccessControlPolicy.cs Xml/Bucket.cs Errors/ErrorResponse.cs ObjectStorageClient.cs ObjectStat.cs Properties/AssemblyInfo.cs V4Authenticator.cs Xml/CreateBucketConfiguration.cs Xml/Grant.cs Xml/GranteeUser.cs Xml/InitiateMultipartUploadResult.cs Xml/Item.cs Xml/ListAllMyBucketsResult.cs Xml/ListBucketResult.cs Xml/ListMultipartUploadsResult.cs Xml/ListPartsResult.cs Xml/Part.cs Xml/Prefix.cs Xml/Upload.cs obj/Release/.NETFramework,Version=v4.5.AssemblyAttribute.cs /target:library /define:TRACE /nostdlib /reference:../packages/RestSharp.105.1.0/lib/net45/RestSharp.dll /reference:/usr/lib/mono/4.5/System.dll /reference:/usr/lib/mono/4.5/System.Xml.Linq.dll /reference:/usr/lib/mono/4.5/System.Data.DataSetExtensions.dll /reference:/usr/lib/mono/4.5/Microsoft.CSharp.dll /reference:/usr/lib/mono/4.5/System.Data.dll /reference:/usr/lib/mono/4.5/System.Xml.dll /reference:/usr/lib/mono/4.5/System.Core.dll /reference:/usr/lib/mono/4.5/mscorlib.dll /warn:4
CSC: error CS2001: Source file `Errors/ConnectionException.cs' could not be found
CSC: error CS2001: Source file `Errors/AccessDeniedException.cs' could not be found
CSC: error CS2001: Source file `Errors/MethodNotAllowedException.cs' could not be found
CSC: error CS2001: Source file `Errors/ForbiddenException.cs' could not be found
CSC: error CS2001: Source file `Errors/InternalServerException.cs' could not be found
CSC: error CS2001: Source file `Errors/RedirectionException.cs' could not be found
CSC: error CS2001: Source file `Errors/ObjectNotFoundException.cs' could not be found
CSC: error CS2001: Source file `Errors/ObjectExistsException.cs' could not be found
CSC: error CS2001: Source file `Errors/MaxBucketsReachedException.cs' could not be found
CSC: error CS2001: Source file `Errors/InvalidRangeException.cs' could not be found
CSC: error CS2001: Source file `Errors/InvalidKeyNameException.cs' could not be found
CSC: error CS2001: Source file `Errors/InvalidBucketNameException.cs' could not be found
CSC: error CS2001: Source file `Errors/InvalidAclNameException.cs' could not be found
CSC: error CS2001: Source file `Errors/InternalClientException.cs' could not be found
CSC: error CS2001: Source file `Errors/BucketNotFoundException.cs' could not be found
CSC: error CS2001: Source file `Errors/BucketExistsException.cs' could not be found
CSC: error CS2001: Source file `Errors/DataSizeMismatchException.cs' could not be found
CSC: error CS2001: Source file `Errors/ClientException.cs' could not be found
CSC: error CS2001: Source file `Xml/AccessControlPolicy.cs' could not be found
CSC: error CS2001: Source file `Xml/Bucket.cs' could not be found
CSC: error CS2001: Source file `Errors/ErrorResponse.cs' could not be found
CSC: error CS2001: Source file `Xml/CreateBucketConfiguration.cs' could not be found
CSC: error CS2001: Source file `Xml/Grant.cs' could not be found
CSC: error CS2001: Source file `Xml/GranteeUser.cs' could not be found
CSC: error CS2001: Source file `Xml/InitiateMultipartUploadResult.cs' could not be found
CSC: error CS2001: Source file `Xml/Item.cs' could not be found
CSC: error CS2001: Source file `Xml/ListAllMyBucketsResult.cs' could not be found
CSC: error CS2001: Source file `Xml/ListBucketResult.cs' could not be found
CSC: error CS2001: Source file `Xml/ListMultipartUploadsResult.cs' could not be found
CSC: error CS2001: Source file `Xml/ListPartsResult.cs' could not be found
CSC: error CS2001: Source file `Xml/Part.cs' could not be found
CSC: error CS2001: Source file `Xml/Prefix.cs' could not be found
CSC: error CS2001: Source file `Xml/Upload.cs' could not be found

Fix CS0168 and CS0219 warnings


Build FAILED.
Warnings:
/home/travis/build/minio/minio-dotnet/Minio.Client.sln (default targets) ->
(Build target) ->
/home/travis/build/minio/minio-dotnet/Minio.Client/Minio.Client.csproj (default targets) ->
/usr/lib/mono/xbuild/12.0/bin/Microsoft.CSharp.targets (CoreCompile target) ->
    Client.cs(322,50): warning CS0168: The variable `ex' is declared but never used
    Client.cs(676,17): warning CS0219: The variable `queries' is assigned but its value is never used
Errors:
/home/travis/build/minio/minio-dotnet/Minio.Client.sln (default targets) ->
(Build target) ->
/home/travis/build/minio/minio-dotnet/Minio.Client/Minio.Client.csproj (default targets) ->
/usr/lib/mono/xbuild/12.0/bin/Microsoft.Common.targets (_CopyAppConfigFile target) ->
    /usr/lib/mono/xbuild/12.0/bin/Microsoft.Common.targets: error : Cannot copy /home/travis/build/minio/minio-dotnet/Minio.Client/App.config to /home/travis/build/minio/minio-dotnet/Minio.Client/bin/Release/Minio.Client.dll.config, as the source file doesn't exist.
     2 Warning(s)
     1 Error(s)

SetBucketAcl does not return error on failure

Each of these fails due to expected exception not being thrown.

        [TestMethod]
        [ExpectedException(typeof(RequestException))]
        public void TestAclNonExistingBucket()
        {
            client.SetBucketAcl(bucket + "-no-exist", Acl.AuthenticatedRead);
        }


        [TestMethod]
        [ExpectedException(typeof(RequestException))]
        public void TestSetAclNotOwned()
        {
            standardClient.SetBucketAcl("bucket", Acl.AuthenticatedRead);
        }


        [TestMethod]
        [ExpectedException(typeof(RequestException))]
        public void TestSetAclDifferentRegion()
        {
            standardClient.SetBucketAcl(bucket, Acl.AuthenticatedRead);
        }


        [TestMethod]
        [ExpectedException(typeof(RequestException))]
        public void TestSetAclDifferentRegionNotOwned()
        {
            standardClient.SetBucketAcl("bucket", Acl.AuthenticatedRead);
        }

Implement http request tracing

implement apis:
TraceOn(traceFilePath)
TraceOff()
This should trace the HTTP calls made similar to mc --debug and also should trace any useful information - like if the region is getting used from cache, region map invalidation, if during resume of putObject/fPutObject it should log if it is continuing from where it left off or reuploading etc.
In the functional tests tracing should be 'on'. We should regularly monitor the functional test log to make sure that it is printing what is expected.

convert minio-dotnet to a stateless library

Convert the APIs to follow this style:

        config := minio.Config{
                AccessKeyID:     "YOUR-ACCESS-KEY-HERE",
                SecretAccessKey: "YOUR-PASSWORD-HERE",
        }

        // Default is Signature Version 4. To enable Signature Version 2 do the following.
        // config.Signature = minio.SignatureV2

        reader, stat, err := minio.GetObject(config, "https://s3.amazonaws.com/bucket/object") {
        if err != nil {
                log.Fatalln(err)
        }  

Fix missing App.config from repository

Without App.config mono build fails


/home/travis/build/minio/minio-dotnet/Minio.Client.sln (default targets) ->
(Build target) ->
/home/travis/build/minio/minio-dotnet/Minio.Client/Minio.Client.csproj (default targets) ->
/usr/lib/mono/xbuild/12.0/bin/Microsoft.Common.targets (_CopyAppConfigFile target) ->
    /usr/lib/mono/xbuild/12.0/bin/Microsoft.Common.targets: error : Cannot copy /home/travis/build/minio/minio-dotnet/Minio.Client/App.config to /home/travis/build/minio/minio-dotnet/Minio.Client/bin/Release/Minio.Client.dll.config, as the source file doesn't exist.
     0 Warning(s)
     1 Error(s)
Time Elapsed 00:00:00.5549170

Figure out what these warning messages are.

Build succeeded.

Warnings:

/home/harsha/repos/minio-dotnet/Minio.sln (default targets) ->
(Build target) ->
/home/harsha/repos/minio-dotnet/Minio/Minio.csproj (default targets) ->
/usr/lib/mono/xbuild/12.0/bin/Microsoft.Common.targets (ResolveAssemblyReferences target) ->

    /usr/lib/mono/xbuild/12.0/bin/Microsoft.Common.targets:  warning : Reference 'System.Data.DataSetExtensions' not resolved
    /usr/lib/mono/xbuild/12.0/bin/Microsoft.Common.targets:  warning : Reference 'System.Data' not resolved

/home/harsha/repos/minio-dotnet/Minio.sln (default targets) ->
(Build target) ->
/home/harsha/repos/minio-dotnet/Minio.Examples/Minio.Examples.csproj (default targets) ->
/usr/lib/mono/xbuild/12.0/bin/Microsoft.Common.targets (ResolveAssemblyReferences target) ->

    /usr/lib/mono/xbuild/12.0/bin/Microsoft.Common.targets:  warning : Reference 'System.Linq' not resolved
    /usr/lib/mono/xbuild/12.0/bin/Microsoft.Common.targets:  warning : Reference 'System.Threading.Tasks' not resolved
    /usr/lib/mono/xbuild/12.0/bin/Microsoft.Common.targets:  warning : Reference 'System.Data.DataSetExtensions' not resolved
    /usr/lib/mono/xbuild/12.0/bin/Microsoft.Common.targets:  warning : Reference 'System.Data' not resolved

     6 Warning(s)
     0 Error(s)

Time Elapsed 00:00:00.3835680

unexpected "GetObject " behavior with play server

I am running GetObject example from minio-dotnet client library & getting these issues. Both bucket and object exists on play server

$ mc ls play/kline/
[2016-03-22 21:03:54 IST]    13B hello.txt

Configuration file:

var client = new MinioClient("https://play.minio.io:9000", "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
$ mono Minio.Examples/GetObject.exe
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InternalError</Code><Message>We encountered an internal error, please try again.</Message><Key></Key><BucketName></BucketName><Resource>/kline/hello.txt</Resource><RequestId>3L137</RequestId><HostId>3L137</HostId></Error>
Unhandled Exception:
Unsuccessful response from server without XML error: InternalServerError: Minio.Errors.InternalClientException: Unsuccessful response from server without XML error: InternalServerError
  at Minio.MinioClient.ParseError (IRestResponse response) <0x41062000 + 0x00dbf> in <filename unknown>:0
  at Minio.MinioClient.GetObject (System.String bucketName, System.String objectName, System.Action`1 callback) <0x40fbcc40 + 0x000eb> in <filename unknown>:0
  at Minio.Examples.GetObject.Main () <0x40f9ed50 + 0x000ef> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: Unsuccessful response from server without XML error: InternalServerError: Minio.Errors.InternalClientException: Unsuccessful response from server without XML error: InternalServerError
  at Minio.MinioClient.ParseError (IRestResponse response) <0x41062000 + 0x00dbf> in <filename unknown>:0
  at Minio.MinioClient.GetObject (System.String bucketName, System.String objectName, System.Action`1 callback) <0x40fbcc40 + 0x000eb> in <filename unknown>:0
  at Minio.Examples.GetObject.Main () <0x40f9ed50 + 0x000ef> in <filename unknown>:0

No ACL related examples

minio-dotnet client library does not provide any example related to ACL [access control list]

Unexpected output while running "ListBuckets"

I have installed minio-dotnet client library & provided it AWS and Play server credentials. I got following error.

$ vim Minio.Examples/ListBuckets.cs $ mcs /r:Minio/bin/Release/Minio.dll Minio.Examples/ListBuckets.cs
$ mono Minio.Examples/ListBuckets.exe

Unhandled Exception:
System.InvalidOperationException: There was an error reflecting type 'Minio.Xml.ListAllMyBucketsResult'. ---> System.InvalidOperationException: Cannot serialize member 'Minio.Xml.ListAllMyBucketsResult.Buckets' of type 'System.Collections.Generic.IReadOnlyCollection`1[[Minio.Xml.Bucket, Minio, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]', see inner exception for more details. ---> System.NotSupportedException: Cannot serialize member Minio.Xml.ListAllMyBucketsResult.Buckets of type System.Collections.Generic.IReadOnlyCollection`1[[Minio.Xml.Bucket, Minio, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] because it is an interface.
  --- End of inner exception stack trace ---
  at System.Xml.Serialization.StructModel.CheckSupportedMember (System.Xml.Serialization.TypeDesc typeDesc, System.Reflection.MemberInfo member, System.Type type) <0x41b25020 + 0x00273> in <filename unknown>:0
  at System.Xml.Serialization.StructModel.GetPropertyModel (System.Reflection.PropertyInfo propertyInfo) <0x41b24e20 + 0x000ef> in <filename unknown>:0
  at System.Xml.Serialization.StructModel.GetFieldModel (System.Reflection.MemberInfo memberInfo) <0x41b24ca0 + 0x000df> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers (System.Xml.Serialization.StructMapping mapping, System.Xml.Serialization.StructModel model, Boolean openModel, System.String typeName, System.Xml.Serialization.RecursionLimiter limiter) <0x41b23000 + 0x00943> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping (System.Xml.Serialization.StructModel model, System.String ns, Boolean openModel, System.Xml.Serialization.XmlAttributes a, System.Xml.Serialization.RecursionLimiter limiter) <0x41b20620 + 0x003db> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeModel model, System.String ns, ImportContext context, System.String dataType, System.Xml.Serialization.XmlAttributes a, Boolean repeats, Boolean openModel, System.Xml.Serialization.RecursionLimiter limiter) <0x41b1f6f0 + 0x0098f> in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeModel model, System.String ns, ImportContext context, System.String dataType, System.Xml.Serialization.XmlAttributes a, Boolean repeats, Boolean openModel, System.Xml.Serialization.RecursionLimiter limiter) <0x41b1f6f0 + 0x00ccf> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeModel model, System.String ns, ImportContext context, System.String dataType, System.Xml.Serialization.XmlAttributes a, System.Xml.Serialization.RecursionLimiter limiter) <0x41b1f680 + 0x00057> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportElement (System.Xml.Serialization.TypeModel model, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace, System.Xml.Serialization.RecursionLimiter limiter) <0x41b1d8f0 + 0x000d7> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) <0x41b1adc0 + 0x0009b> in <filename unknown>:0
  at System.Xml.Serialization.XmlSerializer..ctor (System.Type type, System.String defaultNamespace) <0x41b01eb0 + 0x0036f> in <filename unknown>:0
  at System.Xml.Serialization.XmlSerializer..ctor (System.Type type) <0x41b01d70 + 0x00013> in <filename unknown>:0
  at Minio.MinioClient.ListBuckets () <0x41a6e4a0 + 0x00183> in <filename unknown>:0
  at Minio.Examples.ListBuckets.Main () <0x41a4fd50 + 0x00067> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: There was an error reflecting type 'Minio.Xml.ListAllMyBucketsResult'. ---> System.InvalidOperationException: Cannot serialize member 'Minio.Xml.ListAllMyBucketsResult.Buckets' of type 'System.Collections.Generic.IReadOnlyCollection`1[[Minio.Xml.Bucket, Minio, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]', see inner exception for more details. ---> System.NotSupportedException: Cannot serialize member Minio.Xml.ListAllMyBucketsResult.Buckets of type System.Collections.Generic.IReadOnlyCollection`1[[Minio.Xml.Bucket, Minio, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] because it is an interface.
  --- End of inner exception stack trace ---
  at System.Xml.Serialization.StructModel.CheckSupportedMember (System.Xml.Serialization.TypeDesc typeDesc, System.Reflection.MemberInfo member, System.Type type) <0x41b25020 + 0x00273> in <filename unknown>:0
  at System.Xml.Serialization.StructModel.GetPropertyModel (System.Reflection.PropertyInfo propertyInfo) <0x41b24e20 + 0x000ef> in <filename unknown>:0
  at System.Xml.Serialization.StructModel.GetFieldModel (System.Reflection.MemberInfo memberInfo) <0x41b24ca0 + 0x000df> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers (System.Xml.Serialization.StructMapping mapping, System.Xml.Serialization.StructModel model, Boolean openModel, System.String typeName, System.Xml.Serialization.RecursionLimiter limiter) <0x41b23000 + 0x00943> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping (System.Xml.Serialization.StructModel model, System.String ns, Boolean openModel, System.Xml.Serialization.XmlAttributes a, System.Xml.Serialization.RecursionLimiter limiter) <0x41b20620 + 0x003db> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeModel model, System.String ns, ImportContext context, System.String dataType, System.Xml.Serialization.XmlAttributes a, Boolean repeats, Boolean openModel, System.Xml.Serialization.RecursionLimiter limiter) <0x41b1f6f0 + 0x0098f> in <filename unknown>:0

▽
 * limitations under the License.
  --- End of inner exception stack trace ---
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeModel model, System.String ns, ImportContext context, System.String dataType, System.Xml.Serialization.XmlAttributes a, Boolean repeats, Boolean openModel, System.Xml.Serialization.RecursionLimiter limiter) <0x41b1f6f0 + 0x00ccf> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeModel model, System.String ns, ImportContext context, System.String dataType, System.Xml.Serialization.XmlAttributes a, System.Xml.Serialization.RecursionLimiter limiter) <0x41b1f680 + 0x00057> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportElement (System.Xml.Serialization.TypeModel model, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace, System.Xml.Serialization.RecursionLimiter limiter) <0x41b1d8f0 + 0x000d7> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) <0x41b1adc0 + 0x0009b> in <filename unknown>:0
  at System.Xml.Serialization.XmlSerializer..ctor (System.Type type, System.String defaultNamespace) <0x41b01eb0 + 0x0036f> in <filename unknown>:0
  at System.Xml.Serialization.XmlSerializer..ctor (System.Type type) <0x41b01d70 + 0x00013> in <filename unknown>:0
  at Minio.MinioClient.ListBuckets () <0x41a6e4a0 + 0x00183> in <filename unknown>:0
  at Minio.Examples.ListBuckets.Main () <0x41a4fd50 + 0x00067> in <filename unknown>:0
$
$ vim Minio.Examples/ListBuckets.cs
$ mcs /r:Minio/bin/Release/Minio.dll Minio.Examples/ListBuckets.cs
$ export MONO_PATH=Minio/bin/Release
$ mono Minio.Examples/ListBuckets.exe

Unhandled Exception:
System.InvalidOperationException: There was an error reflecting type 'Minio.Xml.ListAllMyBucketsResult'. ---> System.InvalidOperationException: Cannot serialize member 'Minio.Xml.ListAllMyBucketsResult.Buckets' of type 'System.Collections.Generic.IReadOnlyCollection`1[[Minio.Xml.Bucket, Minio, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]', see inner exception for more details. ---> System.NotSupportedException: Cannot serialize member Minio.Xml.ListAllMyBucketsResult.Buckets of type System.Collections.Generic.IReadOnlyCollection`1[[Minio.Xml.Bucket, Minio, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] because it is an interface.
  --- End of inner exception stack trace ---
  at System.Xml.Serialization.StructModel.CheckSupportedMember (System.Xml.Serialization.TypeDesc typeDesc, System.Reflection.MemberInfo member, System.Type type) <0x409af020 + 0x00273> in <filename unknown>:0
  at System.Xml.Serialization.StructModel.GetPropertyModel (System.Reflection.PropertyInfo propertyInfo) <0x409aee20 + 0x000ef> in <filename unknown>:0
  at System.Xml.Serialization.StructModel.GetFieldModel (System.Reflection.MemberInfo memberInfo) <0x409aeca0 + 0x000df> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers (System.Xml.Serialization.StructMapping mapping, System.Xml.Serialization.StructModel model, Boolean openModel, System.String typeName, System.Xml.Serialization.RecursionLimiter limiter) <0x409ad000 + 0x00943> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping (System.Xml.Serialization.StructModel model, System.String ns, Boolean openModel, System.Xml.Serialization.XmlAttributes a, System.Xml.Serialization.RecursionLimiter limiter) <0x409abc90 + 0x003db> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeModel model, System.String ns, ImportContext context, System.String dataType, System.Xml.Serialization.XmlAttributes a, Boolean repeats, Boolean openModel, System.Xml.Serialization.RecursionLimiter limiter) <0x409aad60 + 0x0098f> in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeModel model, System.String ns, ImportContext context, System.String dataType, System.Xml.Serialization.XmlAttributes a, Boolean repeats, Boolean openModel, System.Xml.Serialization.RecursionLimiter limiter) <0x409aad60 + 0x00ccf> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeModel model, System.String ns, ImportContext context, System.String dataType, System.Xml.Serialization.XmlAttributes a, System.Xml.Serialization.RecursionLimiter limiter) <0x409aacf0 + 0x00057> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportElement (System.Xml.Serialization.TypeModel model, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace, System.Xml.Serialization.RecursionLimiter limiter) <0x409a8f60 + 0x000d7> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) <0x409a6430 + 0x0009b> in <filename unknown>:0
  at System.Xml.Serialization.XmlSerializer..ctor (System.Type type, System.String defaultNamespace) <0x4099ddc0 + 0x0036f> in <filename unknown>:0
  at System.Xml.Serialization.XmlSerializer..ctor (System.Type type) <0x4099dc80 + 0x00013> in <filename unknown>:0
  at Minio.MinioClient.ListBuckets () <0x4090cd70 + 0x00183> in <filename unknown>:0
  at Minio.Examples.ListBuckets.Main () <0x408d9d50 + 0x00067> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: There was an error reflecting type 'Minio.Xml.ListAllMyBucketsResult'. ---> System.InvalidOperationException: Cannot serialize member 'Minio.Xml.ListAllMyBucketsResult.Buckets' of type 'System.Collections.Generic.IReadOnlyCollection`1[[Minio.Xml.Bucket, Minio, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]', see inner exception for more details. ---> System.NotSupportedException: Cannot serialize member Minio.Xml.ListAllMyBucketsResult.Buckets of type System.Collections.Generic.IReadOnlyCollection`1[[Minio.Xml.Bucket, Minio, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] because it is an interface.
  --- End of inner exception stack trace ---
  at System.Xml.Serialization.StructModel.CheckSupportedMember (System.Xml.Serialization.TypeDesc typeDesc, System.Reflection.MemberInfo member, System.Type type) <0x409af020 + 0x00273> in <filename unknown>:0
  at System.Xml.Serialization.StructModel.GetPropertyModel (System.Reflection.PropertyInfo propertyInfo) <0x409aee20 + 0x000ef> in <filename unknown>:0
  at System.Xml.Serialization.StructModel.GetFieldModel (System.Reflection.MemberInfo memberInfo) <0x409aeca0 + 0x000df> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers (System.Xml.Serialization.StructMapping mapping, System.Xml.Serialization.StructModel model, Boolean openModel, System.String typeName, System.Xml.Serialization.RecursionLimiter limiter) <0x409ad000 + 0x00943> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping (System.Xml.Serialization.StructModel model, System.String ns, Boolean openModel, System.Xml.Serialization.XmlAttributes a, System.Xml.Serialization.RecursionLimiter limiter) <0x409abc90 + 0x003db> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeModel model, System.String ns, ImportContext context, System.String dataType, System.Xml.Serialization.XmlAttributes a, Boolean repeats, Boolean openModel, System.Xml.Serialization.RecursionLimiter limiter) <0x409aad60 + 0x0098f> in <filename unknown>:0

▽

  --- End of inner exception stack trace ---
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeModel model, System.String ns, ImportContext context, System.String dataType, System.Xml.Serialization.XmlAttributes a, Boolean repeats, Boolean openModel, System.Xml.Serialization.RecursionLimiter limiter) <0x409aad60 + 0x00ccf> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeModel model, System.String ns, ImportContext context, System.String dataType, System.Xml.Serialization.XmlAttributes a, System.Xml.Serialization.RecursionLimiter limiter) <0x409aacf0 + 0x00057> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportElement (System.Xml.Serialization.TypeModel model, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace, System.Xml.Serialization.RecursionLimiter limiter) <0x409a8f60 + 0x000d7> in <filename unknown>:0
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) <0x409a6430 + 0x0009b> in <filename unknown>:0

▽
  at System.Xml.Serialization.XmlSerializer..ctor (System.Type type, System.String defaultName
▽
using System.IO;
space) <0x4099ddc0 + 0x0036f> in <filename unknown>:0
  at System.Xml.Serialization.XmlSerializer..ctor (System.Type type) <0x4099dc80 + 0x00013> in <filename unknown>:0
  at Minio.MinioClient.ListBuckets () <0x4090cd70 + 0x00183> in <filename unknown>:0
  at Minio.Examples.ListBuckets.Main () <0x408d9d50 + 0x00067> in <filename unknown>:0

Fix hardcoded user-agent

        private string SystemUserAgent = "minio-dotnet/0.0.1 (Windows 8.1; x86_64)";
        private string CustomUserAgent = "";

        private string FullUserAgent
        {
            get
            {
                return SystemUserAgent + " " + CustomUserAgent;
            }
        }

PUT without multipart does not urlencode path

        [TestMethod]
        public void PutSmallFileWithQuestionMark()
        {
            string filePath = "..\\..\\..\\README.md";
            FileInfo fileInfo = new FileInfo(filePath);
            FileStream file = File.OpenRead(filePath);

            client.PutObject(bucket, "small/ob?ject", fileInfo.Length, "text/plain", file);
        }

All arguments for all functions should have native types

For example in Golang in PresignedGetObject

func (a API) PresignedGetObject(bucket, object string, expires time.Duration) (string, error) {

Expires argument is time.Duration which is a native type under Golang ecosystem, we should make sure that wherever possible we should take native types.

always get a bad request exception when run the sample test.

I setup the minio server and client at 2 windows machines separately, start the minio server at machine-A, and try the mc.exe in another machine-B to connect it with the credential, it works as expected, like list bucket, and upload file. I tried the .net sample test to list bucket or checking if the bucket exist, always got a bad request exception. I checked the console output of minio server and it said -
time="2015-11-25T15:58:50+08:00" level=error msg="Unknown region in authorizatio
n header." Error={Invalid region *errors.errorString [{81 C:/mygo/src/github.com
/minio/minio/api-signature.go main.isValidRegion map[]} {89 C:/mygo/src/github.c
om/minio/minio/api-signature.go main.stripAccessKeyID map[]} {108 C:/mygo/src/gi
thub.com/minio/minio/api-signature.go main.initSignatureV4 map[]} {84 C:/mygo/sr
c/github.com/minio/minio/signature-handler.go main.signatureHandler.ServeHTTP ma
p[]}] map[host.os:windows host.arch:amd64 host.name:SHA2UA0151LHQ host.cpus:8 me
m.heap.total:3.0MB host.lang:go1.5.1 mem.used:2.2MB mem.total:6.1MB mem.heap.use
d:2.2MB]}

Do i miss anything? Thanks in advance.

Set Expect header 100-continue for put requests

     [java] DEBUG [org.apache.http.headers] >> Expect: 100-continue
     [java] DEBUG [org.apache.http.wire]  << "HTTP/1.1 100 Continue[\r][\n]"
     [java] DEBUG [org.apache.http.wire]  << "[\r][\n]"
     [java] DEBUG [org.apache.http.impl.conn.DefaultClientConnection] Receiving response: HTTP/1.1 100 Continue
     [java] DEBUG [org.apache.http.headers] << HTTP/1.1 100 Continue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.