Пример #1
0
        public string GetFileUrl(GetFileUrlParameter param)
        {
            var repository = new InfrastructureRepository();
            var pathObj    = repository.QueryFilePath(new QueryFileParameter()
            {
                AppID   = param.AppID,
                FileKey = param.FileKey
            });
            string outFilePath = pathObj.VirtualPath, fileExt;
            var    size = param.ImageThumbnailSize;

            if (size.HasValue && ImageExts.Contains(fileExt = Path.GetExtension(pathObj.PhysicalPath)))
            {
                string filePath = Path.ChangeExtension(pathObj.PhysicalPath, string.Format("{0},{1}", size.Value.Width, size.Value.Height) + fileExt);
                try
                {
                    if (!File.Exists(filePath))
                    {
                        GDIHelper.MakeThumbnailImage(pathObj.PhysicalPath, filePath, size.Value.Width, size.Value.Height, ThumbnailMode.Zoom);
                    }
                    outFilePath = outFilePath.Replace(Path.GetFileName(pathObj.PhysicalPath), Path.GetFileName(filePath));
                }
                catch (Exception ex)
                {
                    App.LogError(ex, "GetFileUrl");
#if DEBUG
                    throw;
#endif
                }
            }
            return(_config.StorageUrl + outFilePath);
        }