示例#1
0
        public async Task Should_get_info_without_content()
        {
            var documentHandle = DocumentHandle.FromString("Pdf_2");

            await _documentStoreClient.UploadAsync(
                TestConfig.PathToDocumentPdf,
                documentHandle
                );

            // waits for storage
            await UpdateAndWaitAsync().ConfigureAwait(false);

            var format = new DocumentFormat("original");

            var options = new OpenOptions()
            {
                FileName    = "pluto.pdf",
                SkipContent = true
            };

            var reader = _documentStoreClient.OpenRead(documentHandle, format, options);

            using (var downloaded = new MemoryStream())
            {
                await(await reader.OpenStream()).CopyToAsync(downloaded);
                Assert.AreEqual(0, downloaded.Length);
                Assert.AreEqual(72768, reader.ContentLength);
            }
        }
        private static async Task <bool> InnerGetPdf(string workingFolder, DocumentStoreServiceClient client, List <FileToComposeData> files, string handle, DocumentHandle documentHandle, bool pdfExists)
        {
            var pdfData  = client.OpenRead(documentHandle, DocumentFormats.Pdf);
            var tempFile = Path.Combine(workingFolder, Guid.NewGuid() + ".pdf");

            using (var downloaded = new FileStream(tempFile, FileMode.OpenOrCreate, FileAccess.Write))
            {
                var stream = await pdfData.OpenStream();

                stream.CopyTo(downloaded);
            }
            files.Add(FileToComposeData.FromDownloadedPdf(tempFile, handle));
            pdfExists = true;
            return(pdfExists);
        }