mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Modified the upload progress bar to better show the current status.
Fixed teh virus scan stream size not being big enough/matching the upload limit.
This commit is contained in:
parent
d361721a3a
commit
3ea314281f
@ -14,13 +14,20 @@ EndProject
|
|||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
|
Release|x64 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Debug|x64.Deploy.0 = Debug|x64
|
||||||
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Release|Any CPU.Build.0 = Release|Any CPU
|
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{B20317CD-76C6-4A7B-BCE1-E4BEF8E4F964}.Release|x64.Build.0 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -45,6 +45,8 @@ namespace Teknik.Areas.Upload.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public ActionResult Upload(string fileType, string fileExt, string iv, int keySize, int blockSize, bool encrypt, bool saveKey, HttpPostedFileWrapper data, string key = null)
|
public ActionResult Upload(string fileType, string fileExt, string iv, int keySize, int blockSize, bool encrypt, bool saveKey, HttpPostedFileWrapper data, string key = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (Config.UploadConfig.UploadEnabled)
|
if (Config.UploadConfig.UploadEnabled)
|
||||||
{
|
{
|
||||||
@ -62,6 +64,7 @@ namespace Teknik.Areas.Upload.Controllers
|
|||||||
if (Config.UploadConfig.VirusScanEnable)
|
if (Config.UploadConfig.VirusScanEnable)
|
||||||
{
|
{
|
||||||
ClamClient clam = new ClamClient(Config.UploadConfig.ClamServer, Config.UploadConfig.ClamPort);
|
ClamClient clam = new ClamClient(Config.UploadConfig.ClamServer, Config.UploadConfig.ClamPort);
|
||||||
|
clam.MaxStreamSize = Config.UploadConfig.MaxUploadSize;
|
||||||
ClamScanResult scanResult = clam.SendAndScanFile(fileData);
|
ClamScanResult scanResult = clam.SendAndScanFile(fileData);
|
||||||
|
|
||||||
switch (scanResult.Result)
|
switch (scanResult.Result)
|
||||||
@ -71,9 +74,9 @@ namespace Teknik.Areas.Upload.Controllers
|
|||||||
case ClamScanResults.VirusDetected:
|
case ClamScanResults.VirusDetected:
|
||||||
return Json(new { error = new { message = string.Format("Virus Detected: {0}. As per our <a href=\"{1}\">Terms of Service</a>, Viruses are not permited.", scanResult.InfectedFiles.First().VirusName, Url.SubRouteUrl("tos", "TOS.Index")) } });
|
return Json(new { error = new { message = string.Format("Virus Detected: {0}. As per our <a href=\"{1}\">Terms of Service</a>, Viruses are not permited.", scanResult.InfectedFiles.First().VirusName, Url.SubRouteUrl("tos", "TOS.Index")) } });
|
||||||
case ClamScanResults.Error:
|
case ClamScanResults.Error:
|
||||||
break;
|
return Json(new { error = new { message = string.Format("Error scanning the file upload for viruses. {0}", scanResult.RawResult) } });
|
||||||
case ClamScanResults.Unknown:
|
case ClamScanResults.Unknown:
|
||||||
break;
|
return Json(new { error = new { message = string.Format("Unknown result while scanning the file upload for viruses. {0}", scanResult.RawResult) } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,6 +119,11 @@ namespace Teknik.Areas.Upload.Controllers
|
|||||||
}
|
}
|
||||||
return Json(new { error = new { message = "Uploads are disabled" } });
|
return Json(new { error = new { message = "Uploads are disabled" } });
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Json(new { error = new { message = "Exception while uploading file: " + ex.Message } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// User did not supply key
|
// User did not supply key
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
@ -138,7 +138,7 @@ var dropZone = new Dropzone(document.body, {
|
|||||||
<div class="row"> \
|
<div class="row"> \
|
||||||
<div class="col-sm-12 text-center"> \
|
<div class="col-sm-12 text-center"> \
|
||||||
<div class="progress" id="progress-' + fileID + '"> \
|
<div class="progress" id="progress-' + fileID + '"> \
|
||||||
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 0%">0%</div> \
|
<div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 0%">0%</div> \
|
||||||
</div> \
|
</div> \
|
||||||
</div> \
|
</div> \
|
||||||
</div> \
|
</div> \
|
||||||
@ -165,6 +165,8 @@ var dropZone = new Dropzone(document.body, {
|
|||||||
// An error occured
|
// An error occured
|
||||||
$("#progress-" + fileID).children('.progress-bar').css('width', '100%');
|
$("#progress-" + fileID).children('.progress-bar').css('width', '100%');
|
||||||
$("#progress-" + fileID).children('.progress-bar').removeClass('progress-bar-success');
|
$("#progress-" + fileID).children('.progress-bar').removeClass('progress-bar-success');
|
||||||
|
$("#progress-" + fileID).children('.progress-bar').removeClass('progress-bar-striped');
|
||||||
|
$("#progress-" + fileID).children('.progress-bar').removeClass('active');
|
||||||
$("#progress-" + fileID).children('.progress-bar').addClass('progress-bar-danger');
|
$("#progress-" + fileID).children('.progress-bar').addClass('progress-bar-danger');
|
||||||
$("#progress-" + fileID).children('.progress-bar').html('File Too Large');
|
$("#progress-" + fileID).children('.progress-bar').html('File Too Large');
|
||||||
}
|
}
|
||||||
@ -219,6 +221,8 @@ function encryptFile(file, callback) {
|
|||||||
// An error occured
|
// An error occured
|
||||||
$("#progress-" + fileID).children('.progress-bar').css('width', '100%');
|
$("#progress-" + fileID).children('.progress-bar').css('width', '100%');
|
||||||
$("#progress-" + fileID).children('.progress-bar').removeClass('progress-bar-success');
|
$("#progress-" + fileID).children('.progress-bar').removeClass('progress-bar-success');
|
||||||
|
$("#progress-" + fileID).children('.progress-bar').removeClass('progress-bar-striped');
|
||||||
|
$("#progress-" + fileID).children('.progress-bar').removeClass('active');
|
||||||
$("#progress-" + fileID).children('.progress-bar').addClass('progress-bar-danger');
|
$("#progress-" + fileID).children('.progress-bar').addClass('progress-bar-danger');
|
||||||
$("#progress-" + fileID).children('.progress-bar').html('Error Occured');
|
$("#progress-" + fileID).children('.progress-bar').html('Error Occured');
|
||||||
}
|
}
|
||||||
@ -281,11 +285,18 @@ function uploadFile(data, key, iv, filetype, fileExt, fileID, saveKey, serverSid
|
|||||||
}
|
}
|
||||||
|
|
||||||
function uploadProgress(fileID, evt) {
|
function uploadProgress(fileID, evt) {
|
||||||
|
var serverSideEncrypt = $('#serverSideEncrypt').is(':checked');
|
||||||
if (evt.lengthComputable) {
|
if (evt.lengthComputable) {
|
||||||
var percentComplete = Math.round(evt.loaded * 100 / evt.total);
|
var percentComplete = Math.round(evt.loaded * 100 / evt.total);
|
||||||
|
if (serverSideEncrypt && percentComplete == 100) {
|
||||||
|
$('#progress-' + fileID).children('.progress-bar').css('width', '100%');
|
||||||
|
$('#progress-' + fileID).children('.progress-bar').html('Encrypting');
|
||||||
|
}
|
||||||
|
else {
|
||||||
$('#progress-' + fileID).children('.progress-bar').css('width', (percentComplete * (2 / 5)) + 60 + '%');
|
$('#progress-' + fileID).children('.progress-bar').css('width', (percentComplete * (2 / 5)) + 60 + '%');
|
||||||
$('#progress-' + fileID).children('.progress-bar').html(percentComplete + '% Uploaded');
|
$('#progress-' + fileID).children('.progress-bar').html(percentComplete + '% Uploaded');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function uploadComplete(fileID, key, saveKey, serverSideEncrypt, evt) {
|
function uploadComplete(fileID, key, saveKey, serverSideEncrypt, evt) {
|
||||||
@ -299,6 +310,8 @@ function uploadComplete(fileID, key, saveKey, serverSideEncrypt, evt) {
|
|||||||
fullName = fullName + '#' + key;
|
fullName = fullName + '#' + key;
|
||||||
}
|
}
|
||||||
$('#progress-' + fileID).children('.progress-bar').css('width', '100%');
|
$('#progress-' + fileID).children('.progress-bar').css('width', '100%');
|
||||||
|
$("#progress-" + fileID).children('.progress-bar').removeClass('progress-bar-striped');
|
||||||
|
$("#progress-" + fileID).children('.progress-bar').removeClass('active');
|
||||||
$('#progress-' + fileID).children('.progress-bar').html('Complete');
|
$('#progress-' + fileID).children('.progress-bar').html('Complete');
|
||||||
$('#upload-link-' + fileID).html('<p><a href="' + fullName + '" id="full-url-link-' + fileID + '" target="_blank" class="alert-link">' + fullName + '</a></p>');
|
$('#upload-link-' + fileID).html('<p><a href="' + fullName + '" id="full-url-link-' + fileID + '" target="_blank" class="alert-link">' + fullName + '</a></p>');
|
||||||
var keyBtn = '<div class="col-sm-4 text-center" id="key-link-' + fileID + '"> \
|
var keyBtn = '<div class="col-sm-4 text-center" id="key-link-' + fileID + '"> \
|
||||||
@ -333,6 +346,8 @@ function uploadComplete(fileID, key, saveKey, serverSideEncrypt, evt) {
|
|||||||
{
|
{
|
||||||
$('#progress-' + fileID).children('.progress-bar').css('width', '100%');
|
$('#progress-' + fileID).children('.progress-bar').css('width', '100%');
|
||||||
$("#progress-" + fileID).children('.progress-bar').removeClass('progress-bar-success');
|
$("#progress-" + fileID).children('.progress-bar').removeClass('progress-bar-success');
|
||||||
|
$("#progress-" + fileID).children('.progress-bar').removeClass('progress-bar-striped');
|
||||||
|
$("#progress-" + fileID).children('.progress-bar').removeClass('active');
|
||||||
$("#progress-" + fileID).children('.progress-bar').addClass('progress-bar-danger');
|
$("#progress-" + fileID).children('.progress-bar').addClass('progress-bar-danger');
|
||||||
$('#remove-link-' + fileID).text('Clear Upload');
|
$('#remove-link-' + fileID).text('Clear Upload');
|
||||||
if (obj.error != null) {
|
if (obj.error != null) {
|
||||||
@ -347,6 +362,8 @@ function uploadComplete(fileID, key, saveKey, serverSideEncrypt, evt) {
|
|||||||
function uploadFailed(fileID, evt) {
|
function uploadFailed(fileID, evt) {
|
||||||
$('#progress-' + fileID).children('.progress-bar').css('width', '100%');
|
$('#progress-' + fileID).children('.progress-bar').css('width', '100%');
|
||||||
$("#progress-" + fileID).children('.progress-bar').removeClass('progress-bar-success');
|
$("#progress-" + fileID).children('.progress-bar').removeClass('progress-bar-success');
|
||||||
|
$("#progress-" + fileID).children('.progress-bar').removeClass('progress-bar-striped');
|
||||||
|
$("#progress-" + fileID).children('.progress-bar').removeClass('active');
|
||||||
$("#progress-" + fileID).children('.progress-bar').addClass('progress-bar-danger');
|
$("#progress-" + fileID).children('.progress-bar').addClass('progress-bar-danger');
|
||||||
$('#progress-' + fileID).children('.progress-bar').html('Upload Failed');
|
$('#progress-' + fileID).children('.progress-bar').html('Upload Failed');
|
||||||
}
|
}
|
||||||
@ -354,6 +371,8 @@ function uploadFailed(fileID, evt) {
|
|||||||
function uploadCanceled(fileID, evt) {
|
function uploadCanceled(fileID, evt) {
|
||||||
$('#progress-' + fileID).children('.progress-bar').css('width', '100%');
|
$('#progress-' + fileID).children('.progress-bar').css('width', '100%');
|
||||||
$("#progress-" + fileID).children('.progress-bar').removeClass('progress-bar-success');
|
$("#progress-" + fileID).children('.progress-bar').removeClass('progress-bar-success');
|
||||||
|
$("#progress-" + fileID).children('.progress-bar').removeClass('progress-bar-striped');
|
||||||
|
$("#progress-" + fileID).children('.progress-bar').removeClass('active');
|
||||||
$("#progress-" + fileID).children('.progress-bar').addClass('progress-bar-warning');
|
$("#progress-" + fileID).children('.progress-bar').addClass('progress-bar-warning');
|
||||||
$('#progress-' + fileID).children('.progress-bar').html('Upload Canceled');
|
$('#progress-' + fileID).children('.progress-bar').html('Upload Canceled');
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("Teknik")]
|
[assembly: AssemblyCompany("Teknik")]
|
||||||
[assembly: AssemblyProduct("Teknik")]
|
[assembly: AssemblyProduct("Teknik")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
[assembly: AssemblyCopyright("Copyright © 2015 - 2016")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
@ -41,6 +42,7 @@
|
|||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
|
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
|
||||||
@ -633,6 +635,24 @@
|
|||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<OutputPath>bin\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<forms domain=".teknik.io" protection="All" enableCrossAppRedirects="true" name="TeknikAuth" />
|
<forms domain=".teknik.io" protection="All" enableCrossAppRedirects="true" name="TeknikAuth" />
|
||||||
</authentication>
|
</authentication>
|
||||||
<compilation debug="true" targetFramework="4.5.2" />
|
<compilation debug="true" targetFramework="4.5.2" />
|
||||||
<httpRuntime targetFramework="4.5.2" maxRequestLength="1048576" />
|
<httpRuntime targetFramework="4.5.2" maxRequestLength="1048576" executionTimeout="3600" />
|
||||||
<pages buffer="true" enableViewState="false" />
|
<pages buffer="true" enableViewState="false" />
|
||||||
</system.web>
|
</system.web>
|
||||||
<system.webServer>
|
<system.webServer>
|
||||||
@ -95,9 +95,10 @@
|
|||||||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
|
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
|
||||||
</providers>
|
</providers>
|
||||||
</entityFramework>
|
</entityFramework>
|
||||||
<system.data>
|
<system.data>
|
||||||
<DbProviderFactories>
|
<DbProviderFactories>
|
||||||
<remove invariant="MySql.Data.MySqlClient" />
|
<remove invariant="MySql.Data.MySqlClient" />
|
||||||
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
|
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
|
||||||
</DbProviderFactories>
|
</DbProviderFactories>
|
||||||
</system.data></configuration>
|
</system.data>
|
||||||
|
</configuration>
|
Loading…
Reference in New Issue
Block a user