mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Fixed issue where both key and iv aren't stored for upload and it would try to decrypt it.
This commit is contained in:
parent
c3774bd811
commit
7806555a07
@ -93,7 +93,7 @@ namespace Teknik.Areas.API.Controllers
|
|||||||
string fullUrl = Url.SubRouteUrl("upload", "Upload.Download", new { file = upload.Url });
|
string fullUrl = Url.SubRouteUrl("upload", "Upload.Download", new { file = upload.Url });
|
||||||
var returnData = new
|
var returnData = new
|
||||||
{
|
{
|
||||||
url = (saveKey) ? fullUrl : fullUrl + "#" + key,
|
url = (saveKey && !string.IsNullOrEmpty(key)) ? fullUrl : fullUrl + "#" + key,
|
||||||
fileName = upload.Url,
|
fileName = upload.Url,
|
||||||
contentType = contentType,
|
contentType = contentType,
|
||||||
contentLength = contentLength,
|
contentLength = contentLength,
|
||||||
|
@ -119,11 +119,16 @@ namespace Teknik.Areas.Upload.Controllers
|
|||||||
if (System.IO.File.Exists(upload.FileName))
|
if (System.IO.File.Exists(upload.FileName))
|
||||||
{
|
{
|
||||||
// Read in the file
|
// Read in the file
|
||||||
byte[] encData = System.IO.File.ReadAllBytes(upload.FileName);
|
byte[] data = System.IO.File.ReadAllBytes(upload.FileName);
|
||||||
// Decrypt the data
|
|
||||||
byte[] data = AES.Decrypt(encData, upload.Key, upload.IV);
|
|
||||||
|
|
||||||
// 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
|
var cd = new System.Net.Mime.ContentDisposition
|
||||||
{
|
{
|
||||||
FileName = upload.Url,
|
FileName = upload.Url,
|
||||||
|
Loading…
Reference in New Issue
Block a user