Merge pull request #270 from HojouFotytu/develop

remove download functionality
This commit is contained in:
HojouFotytu 2021-02-18 22:58:56 +09:00 committed by GitHub
commit b367515103
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 66 deletions

View File

@ -34,20 +34,6 @@
</button>
</div>
</div>
<div class="col-md-6">
<div class="card-box">
<h4 class="m-t-0 header-title">Download Settings</h4>
<p>
Want to save or share your settings?<br />Download them!
</p>
<a class="btn btn-ptmagic text-uppercase waves-effect waves-light" href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)_get/DownloadFile?f=settings.analyzer.json">
Download Settings
</a>
</div>
</div>
</div>
<div class="row">

View File

@ -1,5 +0,0 @@
@page
@model DownloadFileModel
@{
Layout = null;
}

View File

@ -1,47 +0,0 @@
using System;
using System.Collections;
using System.IO;
using Microsoft.Net.Http.Headers;
using Core.Helper;
namespace Monitor.Pages {
public class DownloadFileModel : _Internal.BasePageModelSecure {
public void OnGet() {
// Initialize Config
base.Init();
// Check we have a log in
if (base.IsLoggedIn(this.HttpContext))
{
InitializeDownload();
}
}
private async void InitializeDownload() {
// Zip the file in an non web accessible folder
string fileName = GetStringParameter("f", "");
string tempFolder = PTMagicMonitorBasePath + System.IO.Path.DirectorySeparatorChar + "tmp" + System.IO.Path.DirectorySeparatorChar;
if (System.IO.File.Exists(PTMagicBasePath + fileName)) {
if (!System.IO.Directory.Exists(tempFolder)) {
System.IO.Directory.CreateDirectory(tempFolder);
}
string sourcefilePath = PTMagicBasePath + fileName;
string destinationFilePath = tempFolder + fileName + ".zip";
ZIPHelper.CreateZipFile(new ArrayList() { sourcefilePath }, destinationFilePath);
// Write out the file
var data = System.IO.File.ReadAllBytes(destinationFilePath);
Response.ContentType = "application/zip";
Response.Headers[HeaderNames.CacheControl] = "no-cache";
Response.Headers[HeaderNames.ContentDisposition] = String.Format("attachment; filename={0}", fileName);
await Response.BodyWriter.WriteAsync(new Memory<byte>(data));
Response.BodyWriter.Complete();
}
}
}
}