3

Using the following code to upload a gzip file to S3:

class Program
{
    public static AWSCredentials credentials;

    static Program()
    {
        var chain = new CredentialProfileStoreChain();
        if (!chain.TryGetAWSCredentials("awsConfig", out credentials))
            throw new Exception("AWS Credentials not found!!");
    }

    static void Main(string[] args)
    {
        var filePath = $@"C:\temp\test.gz";
        UploadFile("myBucket", filePath, "test");
    }

    private static void UploadFile(string bucketName, string filePath, string prefixKey)
    {
        TransferUtility fileTransferUtility = new TransferUtility(new AmazonS3Client(credentials, Amazon.RegionEndpoint.USEast1));

        TransferUtilityUploadRequest fileTransferUtilityRequest = new TransferUtilityUploadRequest
        {
            BucketName = bucketName,
            FilePath = filePath,
            Key = prefixKey,
        };

        fileTransferUtility.Upload(fileTransferUtilityRequest);
        Console.WriteLine("Upload completed");
    }
}

I am getting the error The write operation failed, see inner exception where the inner exception is System.Net.Http.WinHttpException: The connection with the server was terminated abnormally

I thought it could be a network problem so I uploaded the application to an EC2 instance in the same region as the bucket and still getting the same error.

The file test.gz is a file with gzip compression and its size is 274kb.

This problem happens only with some files all compressed the same way.

What could be the reason of this error?

Let me know if you need the file to test.

Here is the complete stack trace: https://pastebin.com/RJ8QSmSK

ferflores
  • 964
  • 2
  • 17
  • 34
  • I don't see the problem anymore now that I split the files into smaller 80kb files, S3 does not like something with my gzip compression files if they are bigger than 200kb. Can't find the answer yet but spliting the files does why I need so far. – ferflores Jul 31 '17 at 15:25
  • Found a similar issue unresolved at https://github.com/aws/aws-sdk-net/issues/580 – ferflores Aug 09 '17 at 00:06
  • I ran the same application with .NET Framework 4.5.2 and there is no error, may be an issue or a missing configuration for net core? – ferflores Aug 09 '17 at 00:30
  • More info: I ran the same application with netcore 1.1 on linux and it works withuot errors – ferflores Aug 09 '17 at 14:50

0 Answers0