{"id":204966,"date":"2013-12-05T17:36:11","date_gmt":"2013-12-05T13:36:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=204966"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=204966","title":{"rendered":"<span class=\"post_title\">Windows Azure Blob-storage: \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 CORS<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u0432\u044b\u0448\u043b\u043e \u043c\u043d\u043e\u0433\u043e <a href=\"http:\/\/habrahabr.ru\/company\/microsoft\/blog\/204758\/\">\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 Windows Azure<\/a>. \u0421\u0440\u0435\u0434\u0438 \u043d\u0438\u0445 \u0434\u043e\u043b\u0433\u043e\u0436\u0434\u0430\u043d\u043d\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 Cross-Origin Resource Sharing \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449. \u042f \u043f\u043b\u043e\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 blob-storage (\u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435) \u0438 \u0432 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u043e\u043f\u0438\u0448\u0443 \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0439.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c (blob-storage) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e CORS, \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u0434\u0437\u0430\u0434\u0430\u0447\u0438:<br \/>  1. \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435<br \/>  2. \u0420\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 CORS<br \/>  3. \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 (Shared Access Signature)<br \/>  4. \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a<\/p>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430<\/h4>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e: \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0439\u0442\u0438 \u0432 \u043f\u043e\u0440\u0442\u0430\u043b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f Azure \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0433\u043e.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">screen<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/aaf\/0e9\/919\/aaf0e99194d37c07afb7fac8f4c411c5.png\"\/><\/div>\n<\/div>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435, \u0442\u043e\u0447\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0438 \u043a\u043b\u044e\u0447 \u0434\u043e\u0441\u0442\u0443\u043f\u0430.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">screen<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/dc2\/33d\/1ff\/dc233d1ff0dec5b843ecc7e4af9a8336.png\"\/><br \/>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/7b2\/ddf\/967\/7b2ddf9673c616bcabcdf8255fdb5704.png\"\/>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432 \u043f\u043e\u0440\u0442\u0430\u043b\u0435 \u0438\u043b\u0438 \u0438\u0437 \u043a\u043e\u0434\u0430.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">screen<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/6c2\/69d\/638\/6c269d638f31d98b0450aa3e8bf3385c.png\"\/>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">c# create blob container<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">CloudStorageAccount account = CloudStorageAccount.Parse(&quot;connectionString&quot;); CloudBlobClient client = account.CreateCloudBlobClient(); CloudBlobContainer container = client.GetContainerReference(&quot;containername&quot;); if (container.CreateIfNotExists()) {     container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob }); } <\/code><\/pre>\n<\/div>\n<\/div>\n<h4>\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 CORS \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430<\/h4>\n<p>  \u041d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 (\u0431\u043b\u043e\u0431, \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c) \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u043e \u043f\u044f\u0442\u0438 CORS-\u043f\u0440\u0430\u0432\u0438\u043b. \u0414\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u0445\u0432\u0430\u0442\u0438\u0442 \u0438 \u043e\u0434\u043d\u043e\u0433\u043e. \u0423 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432.<\/p>\n<h5>\u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0435 \u0434\u043e\u043c\u0435\u043d\u044b<\/h5>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c *, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043e\u0442\u043e\u0432\u0441\u044e\u0434\u0443. \u0414\u043b\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u043e\u043c\u0435\u043d\u043e\u0432, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0445 \u0432\u0441\u0435\u0445 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0438 \u0443\u0447\u0435\u0442\u043e\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 (\u0442.\u0435. \u0435\u0441\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <a href=\"http:\/\/domain.com\">domain.com<\/a>, \u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 c <a href=\"https:\/\/domain.com\">domain.com<\/a> \u0438\u043b\u0438 <a href=\"http:\/\/Domain.com\">Domain.com<\/a> \u0443\u0436\u0435 \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u0442).<\/p>\n<h5>\u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438<\/h5>\n<p>  \u0415\u0441\u043b\u0438 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435, \u043e\u043d \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u0442. \u0414\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430: accept \u0438 content-length, \u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0434\u043b\u044f \u0431\u043b\u043e\u0431\u043e\u0432: x-ms-blob-type, x-ms-blob-content-type \u0438 x-ms-blob-cache-control.<\/p>\n<h5>\u0420\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b<\/h5>\n<p>  \u0421\u043f\u0438\u0441\u043e\u043a \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c. \u0414\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0443\u0436\u0435\u043d \u043c\u0435\u0442\u043e\u0434 PUT.<\/p>\n<h5>\u0421\u0440\u043e\u043a \u0436\u0438\u0437\u043d\u0438<\/h5>\n<p>  \u0412\u0440\u0435\u043c\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 (preflight request), \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u043d \u0443\u0437\u043d\u0430\u0435\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 CORS. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0443 \u0442\u0430\u0440\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0442\u0441\u044f, \u0441\u0442\u043e\u0438\u0442 \u0435\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043c.<\/p>\n<h5>Cors-\u043f\u0440\u0430\u0432\u0438\u043b\u043e<\/h5>\n<p>  \u0415\u0441\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0438\u0437 .net (\u0432\u0441\u0435 \u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0432\u044b\u0448\u0435 \u0438 \u043d\u0438\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e REST-API) \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Microsoft.WindowsAzure.Storage \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438. \u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0435\u0451 \u0434\u043e\u0431\u044b\u0447\u0438 \u2013 nuget.  <\/p>\n<pre><code class=\"bash\">PM&gt; Install-Package WindowsAzure.Storage <\/code><\/pre>\n<pre><code class=\"cs\">CorsRule corsRule = new CorsRule {     AllowedOrigins = new List&lt;string&gt;     {         &quot;http:\/\/allowed.domain.com&quot;,         &quot;https:\/\/allowed.domain.com&quot;     },      AllowedHeaders = new List&lt;string&gt;     {         &quot;x-ms-blob-*&quot;,         &quot;content-type&quot;,         &quot;accept&quot;     },      AllowedMethods = CorsHttpMethods.Put,      MaxAgeInSeconds=60*60 }; <\/code><\/pre>\n<h5>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0443<\/h5>\n<p>  <\/p>\n<pre><code class=\"cs\">ServiceProperties serviceProperties = new ServiceProperties {     \/\/\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0430\u043a\u0430\u044f (\u0438\u043b\u0438 \u043d\u043e\u0432\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f) - \u0442\u043e\u043b\u044c\u043a\u043e \u0443 \u043d\u0435\u0451 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f CORS     DefaultServiceVersion = &quot;2013-08-15&quot;,      \/\/\u0432\u043e\u043e\u0431\u0449\u0435, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435, \u043d\u043e \u0431\u0435\u0437 \u043d\u0438\u0445 NullReference exception     \/\/\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0438\u0445 \u0432 \u0434\u0435\u0444\u043e\u043b\u0442\u044b     Logging = new LoggingProperties     {         Version = &quot;1.0&quot;,         LoggingOperations = LoggingOperations.None     },      HourMetrics = new MetricsProperties     {         Version = &quot;1.0&quot;,         MetricsLevel = MetricsLevel.None     },      MinuteMetrics = new MetricsProperties     {         Version = &quot;1.0&quot;,         MetricsLevel = MetricsLevel.None     } };\t              \/\/\u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u043b\u044f \u043a\u043e\u0440\u0441\u0430 serviceProperties.Cors.CorsRules.Add(corsRule); \/\/\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0443 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 client.SetServiceProperties(serviceProperties); <\/code><\/pre>\n<h4>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430.<\/h4>\n<p>  \u0421 \u044d\u0442\u0438\u043c \u0432\u0441\u0435 \u0442\u043e\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e: \u043a\u043b\u044e\u0447 \u2013 \u044d\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u0430\u044f \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0430\u0434\u0440\u0435\u0441\u0430 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0443. \u0414\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c:  <\/p>\n<pre><code class=\"cs\">CloudBlobContainer container = client.GetContainerReference(&quot;containername&quot;); string key=container.GetSharedAccessSignature(new SharedAccessBlobPolicy {     Permissions = SharedAccessBlobPermissions.Write,     SharedAccessStartTime = DateTime.UtcNow.AddMinutes(-1),    \/\/\u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u043d\u0435\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c     SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(60), \/\/\u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c }) <\/code><\/pre>\n<h4>\u0417\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a<\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0440\u043e\u043f\u0440\u0438\u044f\u0442\u0438\u0439, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a\u0430. <\/p>\n<p>  \u0412 Windows Azure \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u0442\u0438\u043f\u0430 \u0431\u043b\u043e\u0431\u043e\u0432 \u2013 \u0431\u043b\u043e\u0447\u043d\u044b\u0435 \u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u044b\u0435. \u0421\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u044b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0432\u0438\u0434\u0435\u043e, \u0430\u0443\u0434\u0438\u043e, \u0442.\u043f.) \u0438 \u0440\u0435\u0436\u0443\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 512 \u0431\u0430\u0439\u0442. \u0418\u0445 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u2013 1 \u0422\u0431. \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u043b\u043e\u0447\u043d\u044b\u0435 \u0431\u043b\u043e\u0431\u044b, \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432 400\u0413\u0431. \u0414\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a\u0430 \u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e \u0432 \u043e\u0434\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 64\u041c\u0431. \u0422.\u0435. \u0444\u0430\u0439\u043b \u0440\u0435\u0436\u0435\u0442\u0441\u044f \u043d\u0430 \u0431\u043b\u043e\u043a\u0438 \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u044e\u0449\u0438\u0435 64\u041c\u0431 \u0438 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0431\u043b\u043e\u043a\u0438 \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u044e\u0442\u0441\u044f. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0444\u0430\u0439\u043b\u044b \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c\u0441\u044f \u043a\u0443\u0441\u043a\u0430\u043c\u0438 \u043f\u043e 512\u041a\u0431.<\/p>\n<p>  \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c.  <\/p>\n<pre><code class=\"bash\">10 \u041f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u043a\u0443\u0441\u043e\u043a \u0444\u0430\u0439\u043b\u0430 20 \u041e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u043a\u0443\u0441\u043e\u043a \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 30 \u0415\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u043d\u0435 \u043a\u043e\u043d\u0447\u0438\u043b\u0441\u044f \u0413\u041e\u0422\u041e 10 40 \u0421\u043a\u043b\u0435\u0438\u0442\u044c \u0431\u043b\u043e\u043a\u0438 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 <\/code><\/pre>\n<p>  \u041b\u043e\u0433\u0438\u043a\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 \u043d\u0430\u0448\u0435\u043c \u043c\u0438\u0440\u0435 \u0432\u0441\u0451 \u0441\u0442\u0430\u043b\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c, \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p>  \u0427\u0442\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0431\u0443\u0434\u0435\u043c \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u043e\u0432\u043e\u0433\u043e \u0438 \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e FileReader.  <\/p>\n<pre><code class=\"javascript\">var reader=new FileReader(); <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044e \u0431\u043b\u043e\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0435\u0433\u043e \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435:  <\/p>\n<pre><code class=\"javascript\">reader.onloadend = function(e) {     if (e.target.readyState == FileReader.DONE) { \/\/ DONE == 2     \/\/url \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0437 \u0430\u0434\u0440\u0435\u0441\u0430 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u0438\u043c\u0435\u043d\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u0438\u043c\u0435\u043d\u0438 \u0444\u0430\u0439\u043b\u0430, \u043a\u043b\u044e\u0447\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430     \/\/\u0441\u043a\u0430\u0436\u0435\u043c \u043a\u0430\u043a\u043e\u0439 \u043a\u0443\u0441\u043e\u043a \u0444\u0430\u0439\u043b\u0430 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c      var uri = submitUri + '&comp=block&blockid=' + blockIds[blockIds.length - 1];     var requestData = new Uint8Array(e.target.result);     $.ajax({         url: uri,         type: &quot;PUT&quot;,         data: requestData,         processData: false,         \/\/preflight request         beforeSend: function (xhr) {             xhr.setRequestHeader('x-ms-blob-type', 'BlockBlob');             xhr.setRequestHeader('Content-Length', requestData.length);         },         success: function () {             bytesUploaded += requestData.length;             var percentage = ((parseFloat(bytesUploaded) \/ parseFloat(files[fileIndex].size)) * 100).toFixed(2);             $('#progress_'+fileIndex).text('\u0417\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043e : ' + percentage + '%');             processFile();         },         error: function () {             $('#progress_' + fileIndex).text('\u0421\u0431\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438');         }     }); } <\/code><\/pre>\n<p>  \u0410 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0447\u0442\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430:  <\/p>\n<pre><code class=\"javascript\">function processFile() {     if (bytesRemain &gt; 0) {         \/\/\u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0447\u0430\u043d\u043a\u0430         blockIds.push(btoa(blockId()));          \/\/\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u0443\u0441\u043e\u043a \u0444\u0430\u0439\u043b\u0430         var fileContent = files[fileIndex].slice(streamPointer, streamPointer + blockSize);         reader.readAsArrayBuffer(fileContent);         streamPointer += blockSize;         bytesRemain -= blockSize;         if (bytesRemain &lt; blockSize) {             blockSize = bytesRemain;         }     } else {         \/\/\u0432\u0441\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0438, \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0442\u043e\u0440\u0435\u0434\u0436\u0443 \u0441\u043a\u043b\u0435\u0438\u0442\u044c \u0431\u043b\u043e\u043a\u0438         commitBlocks();     } } <\/code><\/pre>\n<p>  \u041a\u043e\u0433\u0434\u0430, \u0447\u0442\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e \u0438 \u0432\u0441\u0435 \u0431\u043b\u043e\u043a\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0443, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u043e \u0441\u043a\u043b\u0435\u0438\u043b\u043e \u0431\u043b\u043e\u043a\u0438.  <\/p>\n<pre><code class=\"javascript\">function commitBlocks() {     \/\/\u0441\u043a\u0430\u0436\u0435\u043c \u043a\u0430\u043a\u0438\u0435 \u0431\u043b\u043e\u043a\u0438 \u0441\u043a\u043b\u0435\u0432\u0430\u0442\u044c     var uri = submitUri + '&comp=blocklist';     var requestBody = '&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;BlockList&gt;';     for (var i = 0; i &lt; blockIds.length; i++) {         requestBody += '&lt;Latest&gt;' + blockIds[i] + '&lt;\/Latest&gt;';     }     requestBody += '&lt;\/BlockList&gt;';     $.ajax({         url: uri,         type: 'PUT',         data: requestBody,         beforeSend: function (xhr) { \t\t\/\/\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c mime-type \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u0430, \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e             xhr.setRequestHeader('x-ms-blob-content-type', files[fileIndex].type);             \/\/\u0432\u0441\u0451 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0442\u0430\u0440\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0442\u0441\u044f, \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u043c \u043a\u044d\u0448             xhr.setRequestHeader('x-ms-blob-cache-control', 'max-age=31536000');             xhr.setRequestHeader('Content-Length', requestBody.length);         },         success: function () {             $('#progress_' + fileIndex).text('');             ($('&lt;a&gt;').attr('href', storageurl + files[fileIndex].name).text(files[fileIndex].name)).appendTo($('#progress_' + fileIndex));             fileIndex++;             startUpload();         },         error: function () {             $('#progress_' + fileIndex).text('\u0421\u0431\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438');         }     }); } <\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 CORS, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u044f \u0441\u0432\u043e\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0418 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e: \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440, \u043c\u0435\u043d\u044c\u0448\u0435 \u0438\u0445 \u043d\u0430\u0434\u043e, \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0435\u043d\u0435\u0433 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435.<\/p>\n<p>  \u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430: <a href=\"https:\/\/github.com\/unconnected4\/CORSatWindowsAzureBlobStorage\">https:\/\/github.com\/unconnected4\/CORSatWindowsAzureBlobStorage<\/a><\/p>\n<h6>\u0421\u0441\u044b\u043b\u043a\u0438 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f:<\/h6>\n<p>  <a href=\"http:\/\/habrahabr.ru\/post\/109079\/\">HTML5 File API: \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440<\/a><br \/>  <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windowsazure\/dd179451.aspx\">Put Blob (REST-API)<\/a> \u2014 \u0432\u0430\u0436\u0435\u043d \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432<br \/>  <a href=\"http:\/\/gauravmantri.com\/2013\/12\/01\/windows-azure-storage-and-cors-lets-have-some-fun\/\">Windows Azure Storage and Cross-Origin Resource Sharing (CORS) \u2013 Lets Have Some Fun<\/a><br \/>  <a href=\"http:\/\/gauravmantri.com\/2013\/02\/16\/uploading-large-files-in-windows-azure-blob-storage-using-shared-access-signature-html-and-javascript\/\">Uploading Large Files in Windows Azure Blob Storage Using Shared Access Signature, HTML, and JavaScript<\/a><\/p>\n<p>  <a href=\"https:\/\/plus.google.com\/107862204079203068843?rel=author\">g+<\/a>    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/204966\/\"> http:\/\/habrahabr.ru\/post\/204966\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u0432\u044b\u0448\u043b\u043e \u043c\u043d\u043e\u0433\u043e <a href=\"http:\/\/habrahabr.ru\/company\/microsoft\/blog\/204758\/\">\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 Windows Azure<\/a>. \u0421\u0440\u0435\u0434\u0438 \u043d\u0438\u0445 \u0434\u043e\u043b\u0433\u043e\u0436\u0434\u0430\u043d\u043d\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 Cross-Origin Resource Sharing \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449. \u042f \u043f\u043b\u043e\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 blob-storage (\u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435) \u0438 \u0432 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u043e\u043f\u0438\u0448\u0443 \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0439.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-204966","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/204966","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=204966"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/204966\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=204966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=204966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=204966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}