Our requirement is to upload objects in Amazon S3 using a browser based interface. For this we're utilizing Query String Authentication mechanism (we don't have end-user's credentials during the upload process and we're using ASP.Net to write code to do so. I'm running into issues when trying to do multipart uploads.

I'm using AWS .Net SDK (version 2.0.2.5) to create a query string using the following code below:

            GetPreSignedUrlRequest request = new GetPreSignedUrlRequest()
            {
                BucketName = bucketName,
                Key = objectKey,
                Expires = expiryTime,
                Protocol = Amazon.S3.Protocol.HTTP,
                Verb = Amazon.S3.HttpVerb.PUT,
                ContentType = "application/octet-stream,
            };

var url = AWSClientFactory.CreateAmazonS3Client(credentials, region).GetPreSignedURL(request);

This works great if I don't do multi-part upload. However I'm not able to figure out how to do a multipart upload using Query String.

Problems that I'm running into are:

  1. In order to do a multipart upload, I need to get an UploadId first. However the method to get UploadId is a POST HTTP Request and GetPreSignedUrlRequest method does not take POST as an HTTP verb.
  2. I finally ended up putting a bucket policy where I granted my Amazon S3 account permission on the bucket in question (which does not belong to me) and using that account I am doing HTTP POST to get UploadId.
  3. Now based on my understanding, the query string must contain UploadId and PartNumber parameters when creating the query string authentication URL but looking at GetPreSignedUrlRequest object properties, I can't figure out how to specify these parameters there.

I am inclined to believe that .Net SDK does not support this scenario and I have to resort to native REST API to create query string. Is my understanding correct?

Any insights into this would be highly appreciated.

Happy New Year in advance.

有帮助吗?

解决方案

You are correct in your belief. The AWS SDK for .NET does not currently support creating presigned URLs for multipart uploads

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top