Пример #1
0
        protected Task <Stream> GetBlobFormatReader(
            String tenantId,
            String jobId)
        {
            DocumentStoreServiceClient client = GetDocumentStoreClient(tenantId);
            var reader = client.OpenBlobIdForRead(QueueName, jobId);

            return(reader.OpenStream());
        }
Пример #2
0
        protected async Task <String> DownloadBlob(
            String tenantId,
            String jobId,
            String originalFileName,
            String workingFolder)
        {
            String fileName = Path.Combine(workingFolder, originalFileName);

            //TooLongNames should be truncated, tika, or other libraries are not able to access
            //too long file names. Max file name is 260, but some libraries or task can append some more char
            //ex tika.html
            fileName = SanitizeFileNameForLength(fileName);
            DocumentStoreServiceClient client = GetDocumentStoreClient(tenantId);
            var reader = client.OpenBlobIdForRead(this.QueueName, jobId);

            using (var downloaded = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write))
            {
                var stream = await reader.OpenStream().ConfigureAwait(false);

                stream.CopyTo(downloaded);
            }
            Logger.DebugFormat("Downloaded blob for job {0} for tenant {1} in local file {2}", jobId, tenantId, fileName);
            return(fileName);
        }