public static void PutBucketItem(string itemKey, string bucketName, Stream uploadContent, Action<ProgressResponse> progressHandler = null) { var uploadRequest = new TransferUtilityUploadRequest() .WithBucketName(bucketName) .WithKey(itemKey); try { var awsClient = AWSClientFactory.CreateAmazonS3Client(Properties.Resources.AmazonAccessKeyId, Properties.Resources.SecretAccessKeyId, new AmazonS3Config().WithCommunicationProtocol (Protocol.HTTP)); var fileTransferUtility = new TransferUtility(awsClient); uploadRequest.UploadProgressEvent += (s, e) => { var r = new ProgressResponse { BytesSent = e.TransferredBytes, ProgressPercentage = e.PercentDone, TotalBytesToSend = e.TotalBytes }; if (progressHandler != null) progressHandler(r); }; uploadRequest.WithInputStream(uploadContent); fileTransferUtility.Upload(uploadRequest); } catch (Exception ex) { Log.ErrorFormat("Exception occur writing to amazon S3 server\nException: {0}\nStacktrace: {1}", ex.Message, ex.StackTrace); throw; } }
public void ProgressStatus(ProgressResponse progressResponse) { Assert.IsNotNull(progressResponse); }
private static void ServerConfigProgress(ProgressResponse progressResponse) { //TODO Send Message about uploading progress }