示例#1
0
 public FileUploader(HttpPostedFileBase file, WebApi.File fileEntity)
 {
     _file          = file;
     _containerName = fileEntity.Container;
     _extension     = Path.GetExtension(_file.FileName);
     _contentType   = fileEntity.ContentType;
     _container     = MvcApplication.GetBlobContainer(_containerName);
     _key           = fileEntity.Key;
 }
示例#2
0
        public WebApi.File GetFileEntity()
        {
            // Create new database object to reference the blob from
            var fileEntity = new WebApi.File
            {
                Name          = _file.FileName.Replace(_extension ?? "", ""),
                ContentLength = _file.ContentLength,
                ContentType   = _contentType,
                Key           = _key,
                Container     = _containerName
            };

            return(fileEntity);
        }
示例#3
0
            public static string GetImageUrl(WebApi.File file, string size)
            {
                var keyGuid           = file.Key.Split('.').First();
                var keyExtension      = file.Key.Split('.').Last();
                var keySizeIdentifier = size.Split('/').First();

                var key = string.Format("{0}_{1}.{2}", keyGuid, keySizeIdentifier, keyExtension);

                _container = MvcApplication.GetBlobContainer(file.Container);

                if (_container.GetBlockBlobReference(key)
                    .Exists())
                {
                    return(_container.GetBlockBlobReference(key).Uri.ToString());
                }

                return(_container.GetBlockBlobReference(file.Key).Uri.ToString());
            }
示例#4
0
        /// <summary>
        /// Returns the Url of the given File object
        /// </summary>
        public static string GetFileUrl(WebApi.File file)
        {
            _container = MvcApplication.GetBlobContainer(file.Container);

            return(_container.GetBlockBlobReference(file.Key).Uri.ToString());
        }