public async Task ShouldDownloadSingle() { string contentId = await _fixture.GetRandomContentIdAsync(".jpg", 20); Assert.False(string.IsNullOrEmpty(contentId)); ContentDetail contentDetail = await _client.Contents.GetAsync(contentId); var fileMetadata = contentDetail.GetFileMetadata(); var fileName = new Random().Next(0, 999999).ToString() + "-" + fileMetadata.FileName + ".jpg"; var filePath = Path.Combine(_fixture.TempDirectory, fileName); if (File.Exists(filePath)) { File.Delete(filePath); } using (var response = await _client.Contents.DownloadAsync(contentId, "Original", null, null, "bytes=0-20000000")) { var stream = response.Stream; Assert.Equal(true, stream.CanRead); await response.Stream.WriteToFileAsync(filePath); Assert.True(File.Exists(filePath)); } }
public async Task ShouldGetDocumentMetadata() { var contentId = await _fixture.GetRandomContentIdAsync(".jpg", 20); if (string.IsNullOrEmpty(contentId)) { contentId = await _fixture.GetRandomContentIdAsync(".docx", 20); } Assert.False(string.IsNullOrEmpty(contentId)); ContentDetail result = await _client.Contents.GetAsync(contentId); FileMetadata fileMetadata = result.GetFileMetadata(); Assert.False(string.IsNullOrEmpty(fileMetadata.FileName)); }
public async Task ShouldDownloadSingleResized() { // Download a resized version of an image file var contentId = await _fixture.GetRandomContentIdAsync(".jpg", 20); Assert.False(string.IsNullOrEmpty(contentId)); ContentDetail contentDetail = await _client.Contents.GetAsync(contentId); var fileMetadata = contentDetail.GetFileMetadata(); var fileName = new Random().Next(0, 999999).ToString() + "-" + fileMetadata.FileName + ".jpg"; var filePath = Path.Combine(_fixture.TempDirectory, fileName); if (File.Exists(filePath)) { File.Delete(filePath); } using (var response = await _client.Contents.DownloadAsync(contentId, "Original", 200, 200)) { await response.Stream.WriteToFileAsync(filePath); } Assert.True(File.Exists(filePath)); }