public async Task GetContainerSas() { string fileName = Guid.NewGuid().ToString() + ".containersas.txt"; string filePath = StoragePath.Combine("test", fileName); await _native.WriteTextAsync(filePath, "whack!"); var policy = new ContainerSasPolicy(DateTime.UtcNow, TimeSpan.FromHours(1)); string sas = await _native.GetContainerSasAsync("test", policy, true); //check we can connect and list test file in the root IBlobStorage sasInstance = StorageFactory.Blobs.AzureBlobStorageFromSas(sas); IReadOnlyCollection <Blob> blobs = await sasInstance.ListAsync(StoragePath.RootFolderPath); Blob testBlob = blobs.FirstOrDefault(b => b.FullPath == fileName); Assert.NotNull(testBlob); }
public async Task ContainerPublicAccess() { //make sure container exists await _native.WriteTextAsync("test/one", "test"); await _native.SetContainerPublicAccessAsync("test", ContainerPublicAccessType.Off); ContainerPublicAccessType pa = await _native.GetContainerPublicAccessAsync("test"); Assert.Equal(ContainerPublicAccessType.Off, pa); //it's off by default //set to public await _native.SetContainerPublicAccessAsync("test", ContainerPublicAccessType.Container); pa = await _native.GetContainerPublicAccessAsync("test"); Assert.Equal(ContainerPublicAccessType.Container, pa); }
public async Task GetReadOnlySasUriAsync() { string id = "test/single.txt"; await _native.WriteTextAsync(id, "test"); string uri = await _native.GetReadOnlySasUriAsync(id); string content = await new WebClient().DownloadStringTaskAsync(new Uri(uri)); Assert.Equal("test", content); }