private void putWithRetry(PutObjectRequest request) { // Retry put request up to five times for (int i = 0; i<properties.S3MaxErrorRetry; i++) { try { // Attempt to put the object s3.PutObject(request); log.Info("Successfully uploaded file to S3: " + request.ToString()); return; } catch (AmazonS3Exception exception) { log.Info("Failed to upload file to S3: " + exception.ToString()); Thread.Sleep(properties.S3RetryDelayInterval); } catch (Exception e) { log.Info("Failed to upload file to S3: " + e.ToString()); Thread.Sleep(properties.S3RetryDelayInterval); } } throw new AmazonS3Exception("Failed to upload file to S3"); }