retrieve images from .NET web service stored on azure like blob - c#

Im trying to figure out how to retrieve images from a web service that is connected to azure thats has the images stored as blob.. i just want to be pointed in the right direction, sure if some one have a code example that will be really helpful aswell!
I have not tried any code yet just used google, youtube to find a good example... but no luck.. :/
I can store the images in a folder with the web service if that is easier?

Blobs are accessible using standard URLs. You may need a Shared Access Signature to access the file on a private blob.
I can point you in this direction:
https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/
https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-shared-access-signature-part-1/
Your service should do this (if I understand your need):
Create an output stream
Create in an input stream to a blob object and accessed using a SAS
Connect output stream with input stream
There are plenty of examples around for doing this...

Related

Alternative for the Microsoft Azure C# API

Is there a alternative for the Microsoft Azure C# API. I want to download files from blob urls but a microsoft azure storage account is not for free, so I cannot use it. So is there any other API or way to download blobs?
Example for Blob-Url: blob:https://flex.aniflex.org/afbf9776-76ea-47dc-9951-2fadafc3adff
Caution: I'm not the hoster of the file. So I don't want to download the file from my own storage account.
#kaskorian I guess you're referring to browsers file blobs...Blob URL/Object URL is a pseudo protocol to allow Blob and File objects to be used as URL source for things like images, download links for binary data and so forth.
Blob URLs can only be generated internally by the browser. URL.createObjectURL() will create a special reference to the Blob or File object which later can be released using URL.revokeObjectURL(). These URLs can only be used locally in the single instance of the browser and in the same session (ie. the life of the page/document).
For example, you can not hand an Image object raw byte-data as it would not know what to do with it. It requires for example images (which are binary data) to be loaded via URLs. This applies to anything that require an URL as source. Instead of uploading the binary data, then serve it back via an URL it is better to use an extra local step to be able to access the data directly without going via a server.

Storing Images in Azure and Accessing it in Code

Before I published the website I've been working on to Azure, I kept all the images inside a local "Catalog" folder which was referenced in the program like;
image src='/Catalog/Images/Thumbs/<%#:Item.ImagePath%
Now it is deployed on Azure, I believe I need to turn to something called "Unstructured Blob Storage" to store and retrieve the images on the website.
This is my first time using Azure, I am wondering if it is as easy as storing the images in an unstructured blob storage on Azure, then just changing the "Catalog/Images/Thumbs" to the file path on Azure.
Does anybody know exactly how this works?
Thanks!
AFAIK, after deployed your web application to Azure, you could still store your resources (e.g. image, doc, excel, etc.) within your web application. In order to better manage your resources and reduce the pressure for your application when serving the static resources, you could store your resources in a central data store.
This is my first time using Azure, I am wondering if it is as easy as storing the images in an unstructured blob storage on Azure, then just changing the "Catalog/Images/Thumbs" to the file path on Azure.
Based on your requirement, you could create a blob container named catalog and upload your images to the virtual directory Images/Thumbs, and set anonymous read access to your container and blobs. For a simple way, you could leverage Azure Storage Explorer to upload your images and set access level for your container as follows:
And you image would look like this:
<img src="https://brucchstorage.blob.core.windows.net/catalog/Images/Thumbs/lake.jpeg">
Moreover, you could leverage AzCopy to copy data to Azure Blob storage using simple commands with optimal performance. Additionally, you could leverage Azure Storage client library to manage your storage resources, details you could follow here.

Google storage bucket stats using Cloud Storage Client Libraries

I have a web application that creates/deletes buckets, uploads/downloads objects from google storage and I am successfully using Google Apis Storage v1 and v1.Data in C#.
I would like to know if there is a way to find out how much space a bucket has used using the Google Apis. I was thinking something like StorageClient.GetBucket would return this information but it doesn't seem to.
All the help documentation seems to point to the gsutil but I can't use that as this is for a web application.
So to clarify I am using Cloud Storage Client Libraries
I want to be able to look at any given moment how much space has been used for a particular bucket, using the Google.Storage.Apis (which isn't the XML API or JSON API)
Any help would be very much appreciated.
You can set up bucket logging per Bucket Logging Doc, which will generate a file once a day with the total size (in bytes) of the buckets you defined.
And you've created a feature request as FR/37237171 at the issue tracker.

c# azure mobile services html upload picture

I want to upload a photo from an HTML form post to an Azure Mobile Service written in C#. The issue is that I need to check a security token as well. All of the sample code that I have seen involves uploading to Blob Storage, but I don't want to do that - I need to process the image.
Ideally, I would have a method signature something like this:
void PostMyPicture(string token, byte[] image)
but that method doesn't get dispatched to. I confirmed with Fiddler that the post is happening correctly.
You should use Blob storage because images use a lot of traffic and Azure Mobile Services as a limit of size in the requests. I think will be hard to find sample using AMS that do what you want, but maybe you use a solution for WebAPI that works in AMS.

Importing and showing a local KML file using Google Maps API and GeoXML3

I'm trying to write a desktop application using C# which Google Maps API is embedded in. For this purpose, I embedded a web browser in the application and using Maps API. I could use basic functionalities of the Maps API inside the application.
My purpose is to create a KML file on the fly and show it on the maps. The KML files are successfully created from shapefiles using GDAL. I checked their validity by importing them to the maps.google.com. The problem I'm facing is it is not possible to show KML files on local disk using Maps API. There is no way that I could upload those KML files to a public server that Google can reach. I searched on the web and found that geoxml3 could be used for those purpose but I'm not able to handle it. Since Geoxml3 is subject to same cross-domain download restrictions, I get the "Access denied" error when I try to parse the KML file on my local disk. How could I make sure that my KML document is served from the same domain as the containing map page? I'm pretty new to javascript so any help will be appreciated.
If there is another way of achieving what I'm trying to do(like importing the local kml file to Google servers on the fly,etc.), please tell so. Thank you in advance.
Ekin Gedik
The usual answer to cross-domain issues (at least before recent browsers with CORS: Cross-Origin Resource Sharing, which I have seen but not experimented with), is to use a proxy in the same domain as the web-page. I'm not sure how that will work with a local file though.
You should be able to access a local file from an application running on your local machine, but I'm not sure if that would comply with the terms of use other than for development.
Another option would be to pass the kml to geoxml3 as a string and use parseKmlString method. That would avoid the xmlHttpRequest.

Categories