Browse Source

Fixed issue where both key and iv aren't stored for upload and it would try to decrypt it.

tags/2.0.3
Teknikode 4 years ago
parent
commit
7806555a07

+ 1
- 1
Teknik/Areas/API/Controllers/APIv1Controller.cs View File

@@ -93,7 +93,7 @@ namespace Teknik.Areas.API.Controllers
string fullUrl = Url.SubRouteUrl("upload", "Upload.Download", new { file = upload.Url });
var returnData = new
{
url = (saveKey) ? fullUrl : fullUrl + "#" + key,
url = (saveKey && !string.IsNullOrEmpty(key)) ? fullUrl : fullUrl + "#" + key,
fileName = upload.Url,
contentType = contentType,
contentLength = contentLength,

+ 9
- 4
Teknik/Areas/Upload/Controllers/UploadController.cs View File

@@ -119,11 +119,16 @@ namespace Teknik.Areas.Upload.Controllers
if (System.IO.File.Exists(upload.FileName))
{
// Read in the file
byte[] encData = System.IO.File.ReadAllBytes(upload.FileName);
// Decrypt the data
byte[] data = AES.Decrypt(encData, upload.Key, upload.IV);
byte[] data = System.IO.File.ReadAllBytes(upload.FileName);

// Create File
// If the IV is set, and Key is set, then decrypt it
if (!string.IsNullOrEmpty(upload.Key) && !string.IsNullOrEmpty(upload.IV))
{
// Decrypt the data
data = AES.Decrypt(data, upload.Key, upload.IV);
}

// Create content disposition
var cd = new System.Net.Mime.ContentDisposition
{
FileName = upload.Url,

Loading…
Cancel
Save