Skip to content

Commit 8ab8df5

Browse files
committed
Restructure folders
1 parent 1937f4c commit 8ab8df5

File tree

8 files changed

+23
-2
lines changed

8 files changed

+23
-2
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
using System.Linq;
77
using System.Text;
88
using System.Threading.Tasks;
9+
using Microsoft.WindowsAzure.Storage;
910
using Microsoft.WindowsAzure.Storage.Blob;
11+
using Microsoft.WindowsAzure.Storage.Shared.Protocol;
1012

1113
namespace ASGE
1214
{
1315
class Utility
1416
{
15-
16-
1717
public static void EnsureGzipFiles(CloudBlobContainer container, IEnumerable<string> extensions, bool inPlace, string newExtension, int cacheControlMaxAgeSeconds, bool simulate)
1818
{
1919
Trace.TraceInformation("Enumerating files.");
@@ -103,5 +103,26 @@ public static void EnsureGzipFiles(CloudBlobContainer container, IEnumerable<str
103103

104104
});
105105
}
106+
107+
108+
//acc.SetCORSPropertiesOnBlobService(cors => {
109+
// var wildcardRule = new CorsRule() { AllowedMethods = CorsHttpMethods.Get, AllowedOrigins = { "*" } };
110+
//cors.CorsRules.Add(wildcardRule);
111+
// return cors;
112+
//});
113+
114+
public static void SetCORSPropertiesOnBlobService(this CloudStorageAccount storageAccount,
115+
Func<CorsProperties, CorsProperties> alterCorsRules)
116+
{
117+
if (storageAccount == null || alterCorsRules == null) throw new ArgumentNullException();
118+
119+
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
120+
121+
ServiceProperties serviceProperties = blobClient.GetServiceProperties();
122+
123+
serviceProperties.Cors = alterCorsRules(serviceProperties.Cors) ?? new CorsProperties();
124+
125+
blobClient.SetServiceProperties(serviceProperties);
126+
}
106127
}
107128
}

0 commit comments

Comments
 (0)