Linked Questions

Popular Questions

I have used the sample code from Amazon and it seems to work ok but then fails with the following error:

The XML you provided was not well-formed or did not validate against our published schema

I think the ETags is required though commented out in doc (http://docs.aws.amazon.com/AmazonS3/latest/dev/LLuploadFileDotNet.html). I have been struggling building this.

Code: // List to store upload part responses. List uploadResponses = new List();

    // 1. Initialize.
    InitiateMultipartUploadRequest initiateRequest = new InitiateMultipartUploadRequest
    {
        BucketName = bucketName,
        Key = keyName
    };

    InitiateMultipartUploadResponse initResponse = s3Client.InitiateMultipartUpload(initiateRequest);

    // 2. Upload Parts.
    long contentLength = new FileInfo(fileName).Length;
    long partSize = 5 * (long)Math.Pow(2, 20); // 5 MB

    try
    {
        long filePosition = 0;
        for (int i = 1; filePosition < contentLength; i++)
        {

            // Create request to upload a part.
            UploadPartRequest uploadRequest = new UploadPartRequest
            {
                BucketName = bucketName,
                Key = keyName,
                UploadId = initResponse.UploadId,
                PartNumber = i,
                PartSize = partSize,
                FilePosition = filePosition,
                FilePath = fileName
            };

            // Upload part and add response to our list.
            uploadResponses.Add(s3Client.UploadPart(uploadRequest));
            filePosition += partSize;
        }

        // Step 3: complete.
        CompleteMultipartUploadRequest completeRequest = new CompleteMultipartUploadRequest
        {
            BucketName = bucketName,
            Key = keyName,
            UploadId = initResponse.UploadId
        };

        CompleteMultipartUploadResponse completeUploadResponse =
          s3Client.CompleteMultipartUpload(completeRequest);

        return "Complete";

Related Questions