This repository has been archived by the owner on Aug 1, 2018. It is now read-only.
forked from kirill-kruchkov/azure-storage-gzip-encoding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
66 lines (60 loc) · 2.47 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CommandLine;
using Microsoft.Azure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
namespace ASGE
{
class Program
{
static void Main(string[] args)
{
var options = new Options();
if (CommandLine.Parser.Default.ParseArguments(args, options))
{
if (string.IsNullOrEmpty(options.NewExtension) && !options.Replace)
{
Console.WriteLine("Must provide either -r (in-place replacement) or -n (new extension/postfix to append to compressed version).");
return;
}
CloudStorageAccount storageAccount;
if (!string.IsNullOrEmpty(options.ConnectionString))
{
storageAccount = CloudStorageAccount.Parse(options.ConnectionString);
}
else if (!string.IsNullOrEmpty(options.StorageAccount) && !String.IsNullOrEmpty(options.StorageKey))
{
storageAccount = new CloudStorageAccount(new StorageCredentials(options.StorageAccount, options.StorageKey), true);
}
else
{
options.GetUsage();
return;
}
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer blobContainer = blobClient.GetContainerReference(options.Container);
if (options.GZip)
{
// Do the compression work
Utility.EnsureGzipFiles(blobContainer, options.Extensions, options.Replace, options.NewExtension, options.MaxAgeSeconds, options.Simulate, options.Subpath);
}
else
{
Utility.ApplyCacheControlHeader(blobContainer, options.Extensions, options.Replace, options.NewExtension, options.MaxAgeSeconds, options.Simulate, options.Subpath);
}
// Enable CORS if appropriate
if (options.Wildcard)
{
Utility.SetWildcardCorsOnBlobService(storageAccount);
}
Trace.TraceInformation("Complete.");
}
}
}
}