Beispiel #1
0
        // ReSharper disable once InconsistentNaming
        async Task UploadToAWS(AWSUploadPolicy uploadRequest, FileStream inputStream)
        {
            var s3PostUploadSignedPolicy =
                S3PostUploadSignedPolicy.GetSignedPolicyFromJson(uploadRequest.EncryptedPolicy);

            s3PostUploadSignedPolicy.SecurityToken = uploadRequest.SecurityToken;
            var uploadResponse = await Task.Run(() => AmazonS3Util.PostUpload(new S3PostUploadRequest {
                Key                   = uploadRequest.Key,
                Bucket                = uploadRequest.BucketName,
                CannedACL             = uploadRequest.ACL,
                ContentType           = uploadRequest.ContentType,
                SuccessActionRedirect = uploadRequest.CallbackUrl,
                InputStream           = inputStream,
                SignedPolicy          = s3PostUploadSignedPolicy
            })).ConfigureAwait(false);

            if (uploadResponse.StatusCode != HttpStatusCode.OK)
            {
                throw new Exception("Amazon upload failed: " + uploadResponse.StatusCode);
            }
        }
Beispiel #2
0
 // ReSharper disable once InconsistentNaming
 Task UploadFileToAWS(IAbsoluteFilePath filePath, AWSUploadPolicy uploadRequest) => UploadToAWS(uploadRequest, File.OpenRead(filePath.ToString()));