mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Working on Advanced Encryption Standard (AES), between agent backup and server.
This commit is contained in:
@@ -12,16 +12,21 @@ export async function GET(
|
||||
const expires = searchParams.get('expires');
|
||||
const fileName = (await params).fileName
|
||||
|
||||
const privateLocalDir = "private/uploads/files/";
|
||||
const filePath = path.join(privateLocalDir, fileName);
|
||||
console.log(token);
|
||||
console.log(fileName);
|
||||
|
||||
const uploadsDir = "private/uploads/files/";
|
||||
const keysDir = "private/keys/";
|
||||
const uploadPath = path.join(uploadsDir, fileName);
|
||||
const keyPath = path.join(keysDir, fileName);
|
||||
|
||||
const crypto = require('crypto');
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
return NextResponse.json(
|
||||
{error: 'File not found'},
|
||||
{status: 404}
|
||||
);
|
||||
let filePath = uploadPath;
|
||||
if (!fs.existsSync(uploadPath)) {
|
||||
if (fs.existsSync(keyPath)) filePath = keyPath;
|
||||
else
|
||||
return NextResponse.json({error: "File not found"}, {status: 404});
|
||||
}
|
||||
|
||||
const expectedToken = crypto.createHash('sha256').update(`${fileName}${expires}`).digest('hex');
|
||||
|
||||
Reference in New Issue
Block a user