Ejemplo n.º 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());
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }