public void Create_Rename_Download_Delete_File() { var fileName = Guid.NewGuid().ToString(); var rnd = new Random(); var data = new byte[50]; rnd.NextBytes(data); var create = _filesApi.CreateFile(fileName, "/SDK_Test_Folder", 50, data); Assert.That(create.Name, Is.EqualTo(fileName)); Assert.That(create.Path, Is.EqualTo("/SDK_Test_Folder")); var newName = Guid.NewGuid().ToString(); var updateFile = new UpdateFile("/SDK_Test_Folder", newName); var update = _filesApi.UpdateFileMetadata(create.Id, updateFile); Assert.That(update.Name, Is.EqualTo(newName)); Assert.That(update.Path, Is.EqualTo("/SDK_Test_Folder")); Assert.That(update.Id, Is.EqualTo(create.Id)); var download = _filesApi.DownloadFile(update.Id); var endData = new byte[50]; download.Read(endData); Assert.That(endData, Is.EqualTo(data)); _filesApi.DeleteFile(update.Id); Assert.Throws <ApiException>(() => _filesApi.GetFile(create.Id)); }
public void Download_File() { var rnd = new Random(); var uploadedFile = new byte[100]; rnd.NextBytes(uploadedFile); //Create a unique file name var fileName = Guid.NewGuid().ToString(); //Upload a file var upload = _filesApi.CreateFile(fileName, _testFolder, uploadedFile.Length, uploadedFile); //Create buffer for download var downloadedFile = new byte[100]; //Download file _filesApi.DownloadFile(upload.Id).Read(downloadedFile); Assert.AreEqual(uploadedFile, downloadedFile); }