public void UploadPackage(UploadPackageArgs args) { if (String.IsNullOrEmpty(args.ContainerName)) { args.ContainerName = "received"; } if (String.IsNullOrEmpty(args.CacheControl)) { args.CacheControl = "no-cache"; } if (String.IsNullOrEmpty(args.ContentType)) { args.ContentType = "application/octet-stream"; } CloudStorageAccount account = CloudStorageAccount.Parse(args.StorageConnectionString); CloudBlobClient client = account.CreateCloudBlobClient(); CloudBlobContainer container = client.GetContainerReference(args.ContainerName); if(container.CreateIfNotExists()) { Console.WriteLine("Created '{0}' received container", args.ContainerName); } string filename = args.Path.Substring(args.Path.LastIndexOf('\\') + 1); CloudBlockBlob blob = container.GetBlockBlobReference(filename); blob.Properties.CacheControl = args.CacheControl; blob.Properties.ContentType = args.ContentType; blob.UploadFromFile(args.Path, FileMode.Open); }
public void UploadPackage(UploadPackageArgs args) { if (String.IsNullOrEmpty(args.ContainerName)) { args.ContainerName = "received"; } if (String.IsNullOrEmpty(args.CacheControl)) { args.CacheControl = "no-cache"; } if (String.IsNullOrEmpty(args.ContentType)) { args.ContentType = "application/octet-stream"; } CloudStorageAccount account = CloudStorageAccount.Parse(args.StorageConnectionString); CloudBlobClient client = account.CreateCloudBlobClient(); CloudBlobContainer container = client.GetContainerReference(args.ContainerName); if (container.CreateIfNotExists()) { Console.WriteLine("Created '{0}' received container", args.ContainerName); } string filename = args.Path.Substring(args.Path.LastIndexOf('\\') + 1); CloudBlockBlob blob = container.GetBlockBlobReference(filename); blob.Properties.CacheControl = args.CacheControl; blob.Properties.ContentType = args.ContentType; blob.UploadFromFile(args.Path, FileMode.Open); }