Example #1
0
        public async Task DownloadAsync(FileModel fileModel, Stream output, long from = 0, long to = 0, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (to == 0)
            {
                to = fileModel.Length - 1;
            }

            var fileLocator = await FileStore.FileLocatorGetAsync(fileModel.Identifier);

            var evt = new FileDownloadEvent
            {
                FileIdentifier = fileModel.Identifier
            };

            evt.Populate(fileModel);

            await EventSender.SendAsync(evt);

            await BackendClient.ReadFileAsync(
                await LoadConfigurationAsync(fileModel.Identifier as OrganizationIdentifier),
                fileLocator,
                output,
                from,
                to,
                fileModel.Length,
                cancellationToken
                );
        }
Example #2
0
        public void DeserializeFileDownloadEvent()
        {
            /* GIVEN */
            var deserialized = new FileDownloadEvent();

            /* WHEN */
            deserialized.Deserialize(serializedEvent);

            /* THEN */
            TestCommonAttributes(deserialized);
            Assert.AreEqual(new Uri("https://sample.com/download"), deserialized.FileURL);
            Assert.AreEqual("JSON", deserialized.MIMEType);
        }