feat: enhance JWT authentication and quick import functionality with logging for better traceability
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -15,6 +15,19 @@ export class QuickImportController {
|
||||
FileInterceptor('file', {
|
||||
storage: memoryStorage(),
|
||||
limits: { fileSize: 10 * 1024 * 1024 },
|
||||
fileFilter: (req, file, callback) => {
|
||||
if (
|
||||
file.mimetype === 'application/pdf' ||
|
||||
file.mimetype === 'application/octet-stream' ||
|
||||
file.mimetype === 'image/jpeg' ||
|
||||
file.mimetype === 'image/png' ||
|
||||
file.mimetype === 'image/webp'
|
||||
) {
|
||||
callback(null, true);
|
||||
} else {
|
||||
callback(new Error('Otillåten filtyp. Använd JPEG, PNG, WebP eller PDF.'), false);
|
||||
}
|
||||
},
|
||||
}),
|
||||
)
|
||||
async importFromInput(
|
||||
|
||||
@@ -76,6 +76,8 @@ export class QuickImportService {
|
||||
* Importerar från en uppladdad fil
|
||||
*/
|
||||
async importFromUpload(file: Express.Multer.File): Promise<QuickImportResult | ReceiptImportResult> {
|
||||
this.logger.log('MIME-typ:', file.mimetype);
|
||||
this.logger.log('Token:', file.originalname);
|
||||
const kind = file.mimetype.startsWith('image/') ? 'image' : 'pdf';
|
||||
return this.importFromBuffer(file.buffer, kind);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user