/// <summary> /// 附件下载的直连地址 /// </summary> /// <param name="attachment">附件实体</param> /// <param name="enableClientCaching">是否缓存</param> /// <returns></returns> public string AttachmentDirectUrl(Attachment attachment, bool enableClientCaching = true) { if (attachment == null) { return string.Empty; } string attachmentPath = attachment.GetRelativePath() + "/" + attachment.FileName; if (enableClientCaching) { return storeProvider.GetDirectlyUrl(attachmentPath); } else { return storeProvider.GetDirectlyUrl(attachmentPath, DateTime.Now); } }
/// <summary> /// 获取图片的URL /// </summary> /// <param name="attachment">附件</param> /// <param name="tenantTypeId">租户类型Id</param> /// <param name="imageSizeTypeKey">尺寸类型(通过ImageSizeTypeKeys类获取)</param> /// <param name="enableClientCaching">是否使用客户端缓存</param> /// <returns></returns> public string ImageUrl(Attachment attachment, string tenantTypeId, string imageSizeTypeKey, bool enableClientCaching = true) { if (attachment == null) { return WebUtility.ResolveUrl("~/Themes/Shared/Styles/Images/default_img.png"); } return ImageUrl(attachment.GetRelativePath() + "/" + attachment.FileName, tenantTypeId, imageSizeTypeKey, enableClientCaching); }