Пример #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);
            }
        }
 internal DocumentImportData(Uri uri,string fileName, DocumentHandle handle, DocumentFormat format, string tenant, Guid taskId)
 {
     TaskId = taskId;
     Uri = uri;
     FileName = fileName;
     Handle = handle;
     Format = format;
     Tenant = tenant;
 }
Пример #3
0
        public async Task Should_download_with_range_header()
        {
            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",
                RangeFrom = 0,
                RangeTo   = 199
            };

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

            using (var downloaded = new MemoryStream())
            {
                await(await reader.OpenStream()).CopyToAsync(downloaded);

                Assert.AreEqual(200, downloaded.Length, "Wrong range support");
                Assert.AreEqual(200, reader.ContentLength);
                Assert.AreEqual("bytes 0-199/72768", reader.ReponseHeaders[HttpResponseHeader.ContentRange]);
            }

            //load without rangeto
            options = new OpenOptions()
            {
                FileName  = "pluto.pdf",
                RangeFrom = 200
            };

            reader = _documentStoreClient.OpenRead(documentHandle, format, options);
            using (var downloaded = new MemoryStream())
            {
                await(await reader.OpenStream()).CopyToAsync(downloaded);
                Assert.AreEqual(72768 - 200, downloaded.Length, "Wrong range support");
                Assert.AreEqual(72768 - 200, reader.ContentLength);
                Assert.AreEqual("bytes 200-72767/72768", reader.ReponseHeaders[HttpResponseHeader.ContentRange]);
            }
        }
        public async void should_download_with_range_header()
        {
            var documentHandle = DocumentHandle.FromString("Pdf_2");

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

            // waits for storage
            await UpdateAndWaitAsync();
            var format = new DocumentFormat("original");

            var options = new OpenOptions()
            {
                FileName = "pluto.pdf",
                RangeFrom = 0,
                RangeTo = 199
            };

            var reader = _documentStoreClient.OpenRead(documentHandle, format, options);
            using (var downloaded = new MemoryStream())
            {
                await (await reader.OpenStream()).CopyToAsync(downloaded);

                Assert.AreEqual(200, downloaded.Length, "Wrong range support");
                Assert.AreEqual(200, reader.ContentLength);
                Assert.AreEqual("bytes 0-199/72768", reader.ReponseHeaders[HttpResponseHeader.ContentRange]);
            }

            //load without rangeto
            options = new OpenOptions()
            {
                FileName = "pluto.pdf",
                RangeFrom = 200
            };

            reader = _documentStoreClient.OpenRead(documentHandle, format, options);
            using (var downloaded = new MemoryStream())
            {
                await (await reader.OpenStream()).CopyToAsync(downloaded);
                Assert.AreEqual(72768 - 200, downloaded.Length, "Wrong range support");
                Assert.AreEqual(72768 - 200, reader.ContentLength);
                Assert.AreEqual("bytes 200-72767/72768", reader.ReponseHeaders[HttpResponseHeader.ContentRange]);
            }
        }
        public async void should_get_info_without_content()
        {
            var documentHandle = DocumentHandle.FromString("Pdf_2");

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

            // waits for storage
            await UpdateAndWaitAsync();
            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);
            }
        }
 public bool HasFormat(DocumentFormat format)
 {
     return _formats.ContainsKey(format);
 }