Search code examples
c#minio

Error uploading large files to MinIO server


this is my code:

public async Task UploadFile(string bucketName, Stream fileStream, string fileName, long fileSize, string contentType)
{
            bool found = await minioClient.BucketExistsAsync(bucketName);
            if (!found)
            {
                await minioClient.MakeBucketAsync(bucketName);
            }

            // Upload a file to bucket.
            await minioClient.PutObjectAsync(bucketName, fileName, fileStream, fileSize, contentType);
}

where:

bucketName : "patients"

stream : the resulting stream from an upload to a asp.net web page

fileSize: 19589050

content-type: "application/pdf"

it works fine with smallest PDF files (40KB, 100KB) but if i try to upload biggest files (20 MB for example) i have this exception:

MinIO API responded with message=The request signature we calculated does not match the signature you provided. Check your key and signing method.

STACKTRACE:

in Minio.MinioClient.ParseError(IRestResponse response) in Minio.MinioClient.<>c.<.ctor>b__80_0(IRestResponse response) in Minio.MinioClient.HandleIfErrorResponse(IRestResponse response, IEnumerable`1 handlers, DateTime startTime) in Minio.MinioClient.d__84.MoveNext() --- Fine traccia dello stack da posizione precedente dove è stata generata l'eccezione --- in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in Minio.MinioClient.d__20.MoveNext() --- Fine traccia dello stack da posizione precedente dove è stata generata l'eccezione --- in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) in Minio.MinioClient.d__15.MoveNext() --- Fine traccia dello stack da posizione precedente dove è stata generata l'eccezione --- in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in System.Runtime.CompilerServices.TaskAwaiter.GetResult() in API.Managers.MinIOManager.d__5.MoveNext() in C:\Users\dcalzetta\source\repos\TPO_Web\API\Managers\MinIOManager.cs:riga 43 --- Fine traccia dello stack da posizione precedente dove è stata generata l'eccezione --- in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in System.Runtime.CompilerServices.TaskAwaiter.GetResult() in API.Controllers.DocumentController.d__7.MoveNext() in C:\Users\dcalzetta\source\repos\TPO_Web\API\Controllers\DocumentController.cs:riga 288

where i'm wrong?

i'm using a docker MINIO server for develompent scope,

docker run -d -p 9000:9000 -v /opt/minio/data:/data --restart unless-stopped -e "MINIO_ACCESS_KEY=xxxxxxx" -e "MINIO_SECRET_KEY=yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" minio/minio server /data

in my web.config i extended max upload size to 100Mb,

  <system.web>
    <compilation debug="true" targetFramework="4.6.2" />
    <httpRuntime targetFramework="4.6.1" maxRequestLength="102428" />
  </system.web>

...

  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="102428800" />
      </requestFiltering>
    </security>

Solution

  • I found the problem by myself, The problem is the RestSharp version used on my project, i'm using the latest 106.6.10, and with this version the upload fails. Then I tryed to downgrading step by step, and with the RestSharp to version 106.4.2 (and lower) the upload works without errors!