コード例 #1
0
ファイル: RavenDB_2181.cs プロジェクト: GorelH/ravendb
		public void PutBlobIntoFolder()
		{
			var containerName = "testContainer";
			var blobKey = "folder1/folder2/testKey";

			using (var client = new RavenAzureClient("devstoreaccount1", "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="))
			{
				client.PutContainer(containerName);
				client.PutBlob(containerName, blobKey, new MemoryStream(Encoding.UTF8.GetBytes("123")), new Dictionary<string, string>
				                                                                                        {
					                                                                                        { "property1", "value1" }, 
																											{ "property2", "value2" }
				                                                                                        });
				var blob = client.GetBlob(containerName, blobKey);
				Assert.NotNull(blob);

				using (var reader = new StreamReader(blob.Data))
					Assert.Equal("123", reader.ReadToEnd());

				var property1 = blob.Metadata.Keys.Single(x => x.Contains("property1"));
				var property2 = blob.Metadata.Keys.Single(x => x.Contains("property2"));

				Assert.Equal("value1", blob.Metadata[property1]);
				Assert.Equal("value2", blob.Metadata[property2]);
			}
		}
コード例 #2
0
ファイル: RavenDB-4613.cs プロジェクト: IdanHaim/ravendb
        public async Task put_blob_70MB()
        {
            var containerName = "testContainer";
            var blobKey = "testKey";

            using (var client = new RavenAzureClient(AzureAccountName, AzureAccountKey, containerName, isTest: true))
            {
                await client.PutContainer();
                var sb = new StringBuilder();
                for (var i = 0; i < 70 * 1024 * 1024; i++)
                {
                    sb.Append("a");
                }

                await client.PutBlob(blobKey, new MemoryStream(Encoding.UTF8.GetBytes(sb.ToString())),
                    new Dictionary<string, string>
                    {
                        {"property1", "value1"},
                        {"property2", "value2"}
                    });

                var blob = await client.GetBlob(blobKey);
                Assert.NotNull(blob);

                using (var reader = new StreamReader(blob.Data))
                    Assert.Equal(sb.ToString(), reader.ReadToEnd());

                var property1 = blob.Metadata.Keys.Single(x => x.Contains("property1"));
                var property2 = blob.Metadata.Keys.Single(x => x.Contains("property2"));

                Assert.Equal("value1", blob.Metadata[property1]);
                Assert.Equal("value2", blob.Metadata[property2]);
            }
        }
コード例 #3
0
ファイル: RavenDB_2181.cs プロジェクト: IdanHaim/ravendb
        public async Task PutBlobIntoFolder()
        {
            var containerName = "testContainer";
            var blobKey = "folder1/folder2/testKey";

            using (var client = new RavenAzureClient(AzureAccountName, AzureAccountKey, containerName, isTest: true))
            {
                await client.PutContainer();
                await client.PutBlob(blobKey, new MemoryStream(Encoding.UTF8.GetBytes("123")), new Dictionary<string, string>
                {
                    { "property1", "value1" }, 
                    { "property2", "value2" }
                });

                var blob = await client.GetBlob(blobKey);
                Assert.NotNull(blob);

                using (var reader = new StreamReader(blob.Data))
                    Assert.Equal("123", reader.ReadToEnd());

                var property1 = blob.Metadata.Keys.Single(x => x.Contains("property1"));
                var property2 = blob.Metadata.Keys.Single(x => x.Contains("property2"));

                Assert.Equal("value1", blob.Metadata[property1]);
                Assert.Equal("value2", blob.Metadata[property2]);
            }
        }
コード例 #4
0
		private void UploadToAzure(string backupPath, PeriodicExportSetup localExportConfigs, bool isFullBackup)
		{
			if (azureStorageAccount == Constants.DataCouldNotBeDecrypted ||
				azureStorageKey == 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 RavenAzureClient(azureStorageAccount, azureStorageKey, false))
			{
				client.PutContainer(localExportConfigs.AzureStorageContainer);
				using (var fileStream = File.OpenRead(backupPath))
				{
					var key = Path.GetFileName(backupPath);
					client.PutBlob(localExportConfigs.AzureStorageContainer, key, fileStream, new Dictionary<string, string>
																							  {
																								  { "Description", GetArchiveDescription(isFullBackup) }
																							  });

					logger.Info(string.Format(
						"Successfully uploaded backup {0} to Azure container {1}, with key {2}",
						Path.GetFileName(backupPath),
						localExportConfigs.AzureStorageContainer,
						key));
				}
			}
		}
コード例 #5
0
		private void UploadToAzure(string backupPath, PeriodicExportSetup localExportConfigs, bool isFullBackup)
		{
			using (var client = new RavenAzureClient(azureStorageAccount, azureStorageKey, true))
			{
				client.PutContainer(localExportConfigs.AzureStorageContainer);
				using (var fileStream = File.OpenRead(backupPath))
				{
					var key = Path.GetFileName(backupPath);
					client.PutBlob(localExportConfigs.AzureStorageContainer, key, fileStream, new Dictionary<string, string>
																							  {
																								  { "Description", GetArchiveDescription(isFullBackup) }
																							  });

					logger.Info(string.Format(
						"Successfully uploaded backup {0} to Azure container {1}, with key {2}",
						Path.GetFileName(backupPath),
						localExportConfigs.AzureStorageContainer,
						key));
				}
			}
		}