Cloud API with JavaScript (Amazon, Azure)

前端 未结 5 1973
遇见更好的自我
遇见更好的自我 2021-02-14 06:50

I\'m researching a possibility of using some cloud storage directly from client-side JavaScript. However, I ran into two problems:

  1. Security - t

5条回答
  •  迷失自我
    2021-02-14 07:21

    This can be done with Amazon S3, but not Azure at the moment I think. The reason for this is that S3 supports CORS.

    http://aws.amazon.com/about-aws/whats-new/2012/08/31/amazon-s3-announces-cross-origin-resource-sharing-CORS-support/

    but Azure does not (yet). Also, from your question it sounds like a queuing solution is what you want which suggests Amazon SQS, but SQS does not support CORS either.

    If you need any complex queue semantics (like message expiry or long polling) then S3 is probably not the solution for you. However, if your queuing requirements are simple then S3 could be suitable.

    You would have to have a web service called from the browser with the desired S3 object URL as a parameter. The role of the service is to authenticate and authorize the request, and if successful, generate and return a URL that gives temporary access to the S3 object using query string authentication.

    http://docs.aws.amazon.com/AmazonS3/latest/dev/S3_QSAuth.html

    A neat way might be have the service just redirect to the query string authentication URL.

    For those wondering why this is a Good Thing, it means that you don't have to stream all the S3 object content through your compute tier. You just generate a query string authenticated URL (essentially just a signed string) which is a very cheap operation and then rely on the massive scalability provided by S3 for the actual upload/download.

    Update: As of November this year, Azure now supports CORS on table, queue and blob storage

    http://msdn.microsoft.com/en-us/library/windowsazure/dn535601.aspx

提交回复
热议问题