e8565650e4
# Conflicts: # .gitignore # OurUmbraco.Site/OurUmbraco.Site.csproj # OurUmbraco.Site/Views/MacroPartials/Members/ForgotPassword.cshtml # OurUmbraco.Site/Views/Partials/Members/ForgotPassword.cshtml # OurUmbraco.Site/Views/Partials/Members/Login.cshtml # OurUmbraco.Site/Views/Search/Search.aspx.cs # OurUmbraco.Site/Views/Web.config # OurUmbraco.Site/config/ClientDependency.config # OurUmbraco.Site/config/Dashboard.config # OurUmbraco.Site/config/imageprocessor/cache.config # OurUmbraco.Site/masterpages/Community.master # OurUmbraco.Site/masterpages/ReleaseProgress.master # OurUmbraco.Site/masterpages/Repository/Projects.master # OurUmbraco.Site/masterpages/popular.master # OurUmbraco.Site/packages.config # OurUmbraco/Our/Controllers/LoginController.cs # OurUmbraco/Our/MigrationsHandler.cs # OurUmbraco/OurUmbraco.csproj # OurUmbraco/packages.config
81 lines
2.3 KiB
Plaintext
81 lines
2.3 KiB
Plaintext
@using OurUmbraco.Wiki.BusinessLogic
|
|
@inherits UmbracoTemplatePage
|
|
@{
|
|
Layout = "~/Views/Master.cshtml";
|
|
if (Request["id"] == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int fileId;
|
|
if (int.TryParse(Request["id"], out fileId) == false)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (fileId == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var wikiFile = new WikiFile(fileId);
|
|
|
|
wikiFile.UpdateDownloadCounter(false, wikiFile.FileType == "package");
|
|
using (var sqlHelper = umbraco.BusinessLogic.Application.SqlHelper)
|
|
{
|
|
var path = sqlHelper.ExecuteScalar<string>(
|
|
"Select path from wikiFiles where id = @id;",
|
|
sqlHelper.CreateParameter("@id", fileId));
|
|
|
|
var file = sqlHelper.ExecuteScalar<string>(
|
|
"Select name from wikiFiles where id = @id;",
|
|
sqlHelper.CreateParameter("@id", fileId));
|
|
|
|
var fileinfo = new System.IO.FileInfo(Server.MapPath(path));
|
|
|
|
var extension = System.IO.Path.GetExtension(Server.MapPath(path));
|
|
var type = "";
|
|
// set known types based on file extension
|
|
if (extension != null)
|
|
{
|
|
switch (extension.ToLower())
|
|
{
|
|
case ".tif":
|
|
case ".tiff":
|
|
type = "image/tiff";
|
|
break;
|
|
case ".jpg":
|
|
case ".jpeg":
|
|
type = "image/jpeg";
|
|
break;
|
|
case ".gif":
|
|
type = "image/gif";
|
|
break;
|
|
case ".docx":
|
|
case ".doc":
|
|
case ".rtf":
|
|
type = "Application/msword";
|
|
break;
|
|
case ".pdf":
|
|
type = "Application/pdf";
|
|
break;
|
|
case ".png":
|
|
type = "image/png";
|
|
break;
|
|
case ".bmp":
|
|
type = "image/bmp";
|
|
break;
|
|
default:
|
|
type = "application/octet-stream";
|
|
break;
|
|
}
|
|
}
|
|
|
|
Response.Clear();
|
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename= " + file.Replace(" ", "-"));
|
|
Response.AddHeader("Content-Length", fileinfo.Length.ToString());
|
|
Response.ContentType = type;
|
|
Response.WriteFile(path);
|
|
}
|
|
} |