public async Task LoadFileTestSecureURLAsync() { MemoryStream stream = new MemoryStream(); string fileLoc = Path.Combine(configuration["TestFolderAddress"], "LoadFile", "TestFile.txt"); using (var file = File.OpenRead(fileLoc)) { file.Position = 0; await file.CopyToAsync(stream); } var azureBlob = new AzureBlob(); FileSetOptions fileSetOptions = new FileSetOptions() { FileAccess = FileAccessLevel._public, ConfigurationString = configuration["AzureStorageConnectionString"], Folder = "LoadFilePrivate", Key = "TestFile.txt", _stream = stream }; var fileName = await azureBlob.SaveAsync(fileSetOptions); FileGetOptions fileGetOptions = new FileGetOptions() { ConfigurationString = configuration["AzureStorageConnectionString"], Folder = "LoadFilePrivate", Key = "TestFile.txt", FileTransfer = FileTransferOptions.SecureUrl, SecureLinkTimeToLive = new TimeSpan(0, 0, 5) }; FileData data = await azureBlob.GetAsync(fileGetOptions); HttpClient webClient = new HttpClient(); var fileData = await webClient.GetStringAsync(data.Loc); Assert.IsTrue(fileData.Length > 0); }
public async Task SaveFilePublicTest() { MemoryStream stream = new MemoryStream(); string fileLoc = Path.Combine(configuration["TestFolderAddress"], "LoadFile", "TestFile.txt"); using (var file = File.OpenRead(fileLoc)) { file.Position = 0; await file.CopyToAsync(stream); } var azureBlob = new AzureBlob(); FileSetOptions fileSetOptions = new FileSetOptions() { FileAccess = FileAccessLevel._public, ConfigurationString = configuration["AzureStorageConnectionString"], Folder = "SaveFilePublic", Key = "TestFile.txt", _stream = stream }; var fileName = await azureBlob.SaveAsync(fileSetOptions); HttpClient clinet = new HttpClient(); var rfile = await clinet.GetStringAsync("http://127.0.0.1:10000/devstoreaccount1/savefile/TestFile.txt"); Assert.IsTrue(rfile.Length > 0); }
public async Task SaveFileTestAsync() { MemoryStream stream = new MemoryStream(); string fileLoc = Path.Combine(configuration["TestFolderAddress"], "LoadFile", "TestFile.txt"); using (var file = File.OpenRead(fileLoc)) { file.Position = 0; await file.CopyToAsync(stream); } LocalStorageFileSystem localStorageFileSystem = new LocalStorageFileSystem(); FileSetOptions fileSetOptions = new FileSetOptions() { Address = configuration["TestFolderAddress"], Folder = "SaveFile", Key = "TestFile.txt", _stream = stream }; var fileName = await localStorageFileSystem.SaveAsync(fileSetOptions); string saveFileLoc = Path.Combine(configuration["TestFolderAddress"], "SaveFile", "TestFile.txt"); bool fileExists = File.Exists(saveFileLoc); File.Delete(saveFileLoc); Assert.IsTrue(fileExists); }
public async Task SaveFilePrivateTest() { MemoryStream stream = new MemoryStream(); string fileLoc = Path.Combine(configuration["TestFolderAddress"], "LoadFile", "TestFile.txt"); using (var file = File.OpenRead(fileLoc)) { file.Position = 0; await file.CopyToAsync(stream); } var azureBlob = new AzureBlob(); FileSetOptions fileSetOptions = new FileSetOptions() { FileAccess = FileAccessLevel._private, ConfigurationString = configuration["AzureStorageConnectionString"], Folder = "SaveFilePrivate", Key = "TestFile.txt", _stream = stream }; var fileName = await azureBlob.SaveAsync(fileSetOptions); Assert.IsTrue(fileName != string.Empty); }