public void PutObject() { var bucketName = "ravendb"; var key = "testKey"; using (var client = new RavenAwsS3Client("<aws_access_key>", "<aws_secret_key>", "<aws_region_for_bucket>")) { client.PutObject(bucketName, key, new MemoryStream(Encoding.UTF8.GetBytes("321")), new Dictionary<string, string> { { "property1", "value1" }, { "property2", "value2" } }, 60 * 60); var @object = client.GetObject(bucketName, key); Assert.NotNull(@object); using (var reader = new StreamReader(@object.Data)) Assert.Equal("321", reader.ReadToEnd()); var property1 = @object.Metadata.Keys.Single(x => x.Contains("property1")); var property2 = @object.Metadata.Keys.Single(x => x.Contains("property2")); Assert.Equal("value1", @object.Metadata[property1]); Assert.Equal("value2", @object.Metadata[property2]); } }
private void UploadToS3(string backupPath, PeriodicExportSetup localExportConfigs, bool isFullBackup) { if (awsAccessKey == Constants.DataCouldNotBeDecrypted || awsSecretKey == Constants.DataCouldNotBeDecrypted) { throw new InvalidOperationException("Could not decrypt the AWS access settings, if you are running on IIS, make sure that load user profile is set to true."); } using (var client = new RavenAwsS3Client(awsAccessKey, awsSecretKey, localExportConfigs.AwsRegionEndpoint ?? RavenAwsClient.DefaultRegion)) using (var fileStream = File.OpenRead(backupPath)) { var key = Path.GetFileName(backupPath); client.PutObject(localExportConfigs.S3BucketName, key, fileStream, new Dictionary<string, string> { { "Description", GetArchiveDescription(isFullBackup) } }, 60 * 60); logger.Info(string.Format("Successfully uploaded backup {0} to S3 bucket {1}, with key {2}", Path.GetFileName(backupPath), localExportConfigs.S3BucketName, key)); } }
private void UploadToS3(string backupPath, PeriodicExportSetup localExportConfigs, bool isFullBackup) { using (var client = new RavenAwsS3Client(awsAccessKey, awsSecretKey, localExportConfigs.AwsRegionEndpoint ?? RavenAwsClient.DefaultRegion)) using (var fileStream = File.OpenRead(backupPath)) { var key = Path.GetFileName(backupPath); client.PutObject(localExportConfigs.S3BucketName, key, fileStream, new Dictionary<string, string> { { "Description", GetArchiveDescription(isFullBackup) } }, 60 * 60); logger.Info(string.Format("Successfully uploaded backup {0} to S3 bucket {1}, with key {2}", Path.GetFileName(backupPath), localExportConfigs.S3BucketName, key)); } }