开发者

How to do file upload in Azure-hosted Silverlight?

开发者 https://www.devze.com 2023-01-15 15:32 出处:网络
I am building an app th开发者_JAVA技巧at is entirely Silverlight. It is hosted on Windows Azure. How can I do file upload?

I am building an app th开发者_JAVA技巧at is entirely Silverlight. It is hosted on Windows Azure. How can I do file upload?

There are a number of SL file uploaders, such as this one, which don't work for me because they are stand-alone SL controls - they can't be embedded in my app.

I see a few SL file upload examples that seem straightforward enough, but do I have to do something different for Azure than a normal ASP app?

Thanks.


Aside from WCF tweaks you might need to make (documented here), you need to think about where you'll be storing your file on the server. You can't just write to a local drive. Ok, you can but local storage isn't guaranteed to stick around. Instead, you'll want to consider storing your upload in an Azure blob, which is considered Durable Storage (it's backed up to multiple locations).

If you upload to an Azure blob directly from your Silverlight client, you'll need to connect with the Azure Storage API. You need to be careful about embedding your key within your Silverlight app, and the recommended guidance is to used Shared Access Signatures - see Steve Marx's post for more info about this.

You can also continue to use a WCF service, and having that service method then store your upload to a blob. This gives you the ability to keep your Silverlight app's upload logic intact, and also rely on your service tier to track access to your uploaded file.


You can use REST to make uploads directly to Azure. See my sample doing exactly that with parallelism, reties and cancellations enabled at: Silverlight based parallel upload control

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号