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:
- In order to do a multipart upload, I need to get an
UploadIdfirst. However the method to getUploadIdis aPOSTHTTP Request andGetPreSignedUrlRequestmethod does not takePOSTas an HTTP verb. - 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. - Now based on my understanding, the query string must contain
UploadIdandPartNumberparameters when creating the query string authentication URL but looking atGetPreSignedUrlRequestobject 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.