示例#1
0
        public BoundingBox[] ListBoxes()
        {
            var blobList        = _container.ListBlobs(useFlatBlobListing: true);
            var listOfFileNames = new List <BoundingBox>();

            foreach (var blob in blobList)
            {
                var blobFileName = blob.Uri.Segments.Last();
                listOfFileNames.Add(BoundingBoxFilenameConverter.ParseFileName(blobFileName));
            }

            return(listOfFileNames.ToArray());
        }
示例#2
0
        public Geometry GetBox(BoundingBox box)
        {
            var    filename      = BoundingBoxFilenameConverter.CreateFileName(box, "json");
            var    blobReference = _container.GetBlobReference(filename);
            string text;

            using (var memoryStream = new MemoryStream())
            {
                blobReference.DownloadToStream(memoryStream);
                text = System.Text.Encoding.UTF8.GetString(memoryStream.ToArray());
            }
            return(JsonSerDe.GetGeometry(text));
        }
示例#3
0
        public string Upload(string geometry, BoundingBox box)
        {
            var path = BoundingBoxFilenameConverter.CreateFileName(box, _suffix);

            // todo: move this.
            string storageConnectionString = Environment.GetEnvironmentVariable("");

            if (CloudStorageAccount.TryParse(storageConnectionString, out var storageAccount))
            {
                try
                {
                    CloudBlobClient    cloudBlobClient    = storageAccount.CreateCloudBlobClient();
                    CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference(_path);
                    CloudBlockBlob     cloudBlockBlob     = cloudBlobContainer.GetBlockBlobReference(path);
                    cloudBlockBlob.UploadFromStream(new MemoryStream(Encoding.ASCII.GetBytes(geometry)));
                }
                catch (StorageException ex)
                {
                    Console.WriteLine(ex);
                }
            }

            return(path);
        }