Exemplo n.º 1
0
        public string CreateAssets()
        {
            var storage = new AzureFileStorage();
            var sb      = new StringBuilder();

            string[] assets = new string[] {
                "parchment.jpg",
                "parchment2.jpg",
                "parchment3.jpg",
                "YeOldeParchment4.png",
                "marble1.jpg",
                "paper.jpg",
                "home-parchment22.gif",
                "cloud1.png",
                "cloud2.png",
                "cloud3.png",
                "10277-m-001.wav",
            };

            foreach (var asset in assets)
            {
                byte[] fileData = null;
                using (
                    var localFile = System.IO.File.Open(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/" + asset),
                                                        System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
                {
                    fileData = new byte[localFile.Length];
                    localFile.Read(fileData, 0, fileData.Length);
                }

                storage.Store(string.Concat(ConfigurationManager.AppSettings["AssetsRelativePath"], asset), fileData, true);
                sb.AppendLine(string.Format("Stored {0}", asset));
            }
            return(sb.ToString());
        }