public override void ProcessRequest() { int assetFileId = GetIdFromFilename(); int assetId = WebUtils.GetIntRequestParam("AssetId", 0); if (assetFileId <= 0) { throw new SystemException("Invalid attached file id: " + assetFileId); } if (assetId <= 0) { throw new SystemException("Invalid asset id: " + assetId); } // Get the asset file AssetFile assetFile = AssetFile.Get(assetFileId); if (assetFile.AssetId != assetId) { throw new SystemException("Asset mismatch"); } if (assetFile.IsNull) { throw new SystemException("Asset file not found"); } if (assetFile.Asset.RestrictAttachedFiles && !EntitySecurityManager.CanUserDownloadAsset(SessionInfo.Current.User, assetFile.Asset)) { throw new SystemException("Access denied"); } // Log the download string notes = string.Format("Downloaded file: {0}", assetFile.Filename); AuditLogManager.LogAssetAction(assetFile.AssetId, SessionInfo.Current.User, AuditAssetAction.DownloadedAttachedFile, notes); AuditLogManager.LogUserAction(SessionInfo.Current.User, AuditUserAction.DownloadAttachedFile, notes); // Send the file SiteUtils.SendAttachedFile(assetFile); }
public static void SendAttachedFile(int assetFileId) { // Ensure we have an asset file ID if (assetFileId == 0) { return; } // Get the asset file AssetFile assetFile = AssetFile.Get(assetFileId); // Ensure we have an asset file if (assetFile.IsNull) { return; } // Download filename SendAttachedFile(assetFile); }