How To upload a Photo To Azure Blob with SAS from a WP App? - windows-phone-7

I am able to upload photos to blob with SAS from an Azure MVC web role with the code below:
using (var WS = new HLServiceClient())
{
/* Getting a SAS Write URI */
var sasUri = WS.GetSasUriForBlobWrite(HLServiceReference.BusinessLogicMediaUsage.News, fileName);
var writeBlob = new CloudBlob(sasUri);
writeBlob.UploadFromStream(fileData.InputStream);
}
I would like to do the same thing from a WP app. But I can't figure out how to do it. I DON'T HAVE A LOT OF PROGRAMMING SKILL.
Can you tell me how to upload a photo to blob from a WP app with SAS?
There is a Windows Azure Storage Client Library for Windows Phone available on NuGet: Phone.Storage, it says "Class library for Windows Phone to communicate with Windows Azure storage services directly", I was hoping to find a simple solution using that: http://www.nuget.org/packages/Phone.Storage
I found a video tutorial on the Phone.Storage NuGet:
http://channel9.msdn.com/posts/Using-the-Windows-Phone-Storage-NuGets-for-Windows-Azure
There is also a sample application demonstrating the usage of the Phone.Storage NuGet.
http://www.nuget.org/packages/Phone.Storage.Sample
Still, though, it evades me if I can implement this in my application scenario?

First, you need to generate the SAS from a hosted service. You can use the CloudBlob.GetSharedAccessSignature method (refer to http://msdn.microsoft.com/en-us/library/windowsazure/ee772922.aspx for a sample).
On the Windows Phone side, for small files, you simply need to issue an HTTP request to the SAS URL. You can use HttpWebRequest to do that. Try to search the web, and you can find a lot of samples, such as http://blogs.msdn.com/b/devfish/archive/2011/04/07/httpwebrequest-fundamentals-windows-phone-services-consumption-part-2.aspx.
For large files (larget than 64 MB), you need to divide them into smaller pieces, upload each piece as a block, and then commit the blob list (PUT block list: http://msdn.microsoft.com/en-us/library/windowsazure/dd179467). This is a tedious but not difficult task. You need to create quite a few HTTP requests.
The Windows Azure Toolkit for Windows Phone may also help: http://watwp.codeplex.com/. It contains a library that is similar to the Windows Azure library for .NET.

Related

How to access a web site from a native Windows application?

I hope this is a simple question.
Using .NET, I could simply access a Web site using:
WebClient wc = new WebClient();
wc.Credentials = new NetworkCredential("myUserName", "Password123");
string fileContent = wc.DownloadString("https://example.com/example.txt");
Unfortunately, I am working on a native 64-bit DLL file which is used as plug-in in another program.
So I have no chance to use .NET but I can only use native 64-bit Windows DLLs.
Are there any native Windows APIs that do the same as the code above?
I have searched the Internet, but I found nothing.
I found out the answer myself:
The functions of "wininet.dll" are the solution:
The function InternetOpen() more or less corresponds to new WebClient().
Downloading data is a bit more complicated; there is no unified API for different protocols (HTTP, FTP, ...), but each protocol type uses different functions.
To download (GET) or send (POST) data via HTTP or HTTPS, the APIs InternetCrackUrl(), InternetConnect(), HttpSendRequest() and InternetReadFile() are used.
(Note: On the Microsoft web site documentation, the function declarations are shown as void InternetOpen(...) although the documentation says that the functions return a value of the type HINTERNET. HINTERNET is correct, void is wrong.)

How to Enable the Client-side Logging with the Azure Storage Client Library(Ver 12) for Java

I want to log the request/response at client site with Azure blob storage for Java sdk(ver12).
In microsoft online document [https://learn.microsoft.com/en-us/rest/api/storageservices/client-side-logging-with-the-microsoft-azure-storage-sdk-for-java], I found this sample code.
// Set logging off by default.
OperationContext.setLoggingEnabledByDefault(false);
OperationContext ctx = new OperationContext();
ctx.setLoggingEnabled(true);
// Create an operation to add a new customer to the people table.
TableOperation insertCustomer1 = TableOperation.insertOrReplace(customer1);
// Submit the operation to the table service.
table.execute(insertCustomer1, null, ctx);
But it does not work. OperationContext can not be found in libs. Maybe it is a older version sample.
I hope someone can give me a sample code, Thanks.
The OperationContext is a class of com.microsoft.azure.storage, while the latest version is 8.6.3.
You can get the OperationContext class in Microsoft Azure Storage SDK v8 for Java.
If you would like to access our latest Java SDK, please refer to the Storage SDK v12 for Java link in the table below. If you would like more information on our decision to upgrade our Java SDK and the path forward, please refer to this document. If you would like more information on Azure's burgeoning effort to coordinate the development of the SDKs across services, of which this change is a part, please refer to this article.

azure media service for xamarin?

I have created a console application with azure media service.
in the app i am using the plugin
windowsazure.mediaservices
the way i am doing is
static IAsset CreateAssetAndUploadSingleFile(string filePath, string assetName, AssetCreationOptions options)
{
IAsset asset = _context.Assets.Create(assetName, options);
var assetFile = asset.AssetFiles.Create(Path.GetFileName(filePath));
assetFile.Upload(filePath);
return asset;
}
so i just want to know whether this plugin will work on xamarin(i am not a xamarin devoloper) as its a portable project.
if its not do we have any alternative plugin?
my basic purpose is upload and encode.
That package is for our current .NET SDK
https://www.nuget.org/packages/windowsazure.mediaservices
It does not support .NET Core. See the dependencies.
It's not compiled for Xamarin though, so I don't believe that it works in Xamarin, but i'm not a Xamarin expert at all.
What is your scenario exactly? Why would you want to call the Media Services account directly from Xamarin anyways? You would only need to do that if you are creating a management application for the account Administrator. Otherwise, dont put Media Services directly into any client code! You should hide it in your middle-tier, and only pass Streaming URLs or SAS locators to the client application to upload content to.
For the upload from phone scenario, middle tier should create an Asset, get a writable SAS Locator for the Asset, hand that to the client side. Client can then use Azure Storage APIs to upload the content to that SAS URL directly (it ends up in an Azure storage container then.)
I believe that Xamarin has client side support for the Azure Storage APIs available.
As john answered, you don't do this stuff on a client, you will need to use SaS tokens and what not. I could explain everything here, but there are some nice guides and examples online.
Build 2018 video explaining how it works (including Azure Functions): https://www.youtube.com/watch?v=dEZkQNNpSIQ&feature=youtu.be&rel=0
The github example of this video: https://github.com/Azure-Samples/xamarin-azure-businessreview
To understand it better, I recommend this guide, it is old but it does cover the entire process, just make sure to combine new documentation with this old one.
Old docu: https://learn.microsoft.com/en-us/previous-versions/msp-n-p/dn735912(v%3dpandp.10)
Official current documentation: https://learn.microsoft.com/en-us/azure/media-services/previous/media-services-dotnet-upload-files#upload-multiple-files-with-media-services-net-sdk
Probably useful for new readers.

How can I get image list and download these images from public-shared-gallery-link by using Dropbox SDK?

I want to get the image list and download those images from a Dropbox's public-shared-link, which I get it from my client.
I'm using Dropbox SDK for ruby and only find the methods to manage files via my Dropbox account, such as put_file, get_file, get_file_and_metadata, get_chunked_uploader, upload and so on.
Is there any way to do that?
Dropbox API v1 has an endpoint that allows you to retrieve metadata about shared links:
https://www.dropbox.com/developers-v1/core/docs#metadata-link
Dropbox API v2 has a similar pair of endpoints that allows you to retrieve metadata and file content, respectively, from shared links:
https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_metadata
https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_file
Unfortunately, none of these are currently implemented in the Ruby SDK. You can call them directly though, or modify the Ruby SDK to do so.

Download large file from Skydrive to Windows Phone 7

Am having some trouble with the SkyDrive download process and hoping you can help me.
Following the standard SkyDrive API & examples, I've set up a page that browses the SkyDrive folder structure, lets User click on a file, prompt to download, and it all works correctly.
Where I'm having trouble is when the file downloaded is large, I get the OutOfMemoryException thrown at around the 100Mb mark.
Dennis speaks on this problem here http://dotnet.dzone.com/articles/2-things-you-should-consider but it relates to a direct URL download, not via the SkyDrive architecture.
I've tried extracting the URL from SkyDrive and doing the direct download that way but haven't had any success.
Here is the code I'm using - the "item" object is of type SkyDriveItem, having iterated through a folders content and selected this file.
LiveConnectClient downloadClient = new LiveConnectClient(App.Session);
try
{
downloadClient.DownloadCompleted += new EventHandler<LiveDownloadCompletedEventArgs>(downloadClient_DownloadCompleted);
downloadClient.DownloadProgressChanged += new EventHandler<LiveDownloadProgressChangedEventArgs>(downloadClient_DownloadProgressChanged);
downloadClient.DownloadAsync(item.ID + "/content", item);
This will work fine when the file isn't too large, but as mentioned, select a big file (>100Mb) and it dies with the OutOfMemory exception.
Any pointers?
Thanks in advance
Resolved - While I was never able to use the downloadClient.DownloadAsync() method to download large files, playing with the downloadClient.getAsync() and using the Pre-Authenticated URL via a regular Stream downloader does the trick.

Resources