- removed all controller methods from 'app/Controlles/Http/Admin/UsersControllers.ts' - merged all authentication methods inside 'app/Controllers/Http/Auth/UserController.ts'
This commit is contained in:
parent
68928b5e07
commit
4efa53673f
7 changed files with 133 additions and 187 deletions
|
@ -35,6 +35,7 @@ import { ValidationException } from '@ioc:Adonis/Core/Validator';
|
|||
import Drive from '@ioc:Adonis/Core/Drive';
|
||||
import { Exception } from '@adonisjs/core/build/standalone';
|
||||
import { MultipartFileContract } from '@ioc:Adonis/Core/BodyParser';
|
||||
import * as crypto from 'crypto';
|
||||
|
||||
export default class DatasetController {
|
||||
public async index({ auth, request, inertia }: HttpContextContract) {
|
||||
|
@ -432,8 +433,9 @@ export default class DatasetController {
|
|||
}
|
||||
// clientName: 'Gehaltsschema.png'
|
||||
// extname: 'png'
|
||||
// fieldName: 'file'
|
||||
const fileName = `file-${cuid()}.${file.extname}`;
|
||||
// fieldName: 'file'
|
||||
// const fileName = `file-${this.generateRandomString(32)}.${file.extname}`;
|
||||
const fileName = this.generateFilename(file.extname as string);
|
||||
const mimeType = file.headers['content-type'] || 'application/octet-stream'; // Fallback to a default MIME type
|
||||
const datasetFolder = `files/${dataset.id}`;
|
||||
// const size = file.size;
|
||||
|
@ -460,6 +462,20 @@ export default class DatasetController {
|
|||
}
|
||||
}
|
||||
|
||||
private generateRandomString(length: number): string {
|
||||
return crypto.randomBytes(Math.ceil(length / 2)).toString('hex').slice(0, length);
|
||||
}
|
||||
|
||||
private generateFilename(extension: string): string {
|
||||
const randomString1 = this.generateRandomString(8);
|
||||
const randomString2 = this.generateRandomString(4);
|
||||
const randomString3 = this.generateRandomString(4);
|
||||
const randomString4 = this.generateRandomString(4);
|
||||
const randomString5 = this.generateRandomString(12);
|
||||
|
||||
return `file-${randomString1}-${randomString2}-${randomString3}-${randomString4}-${randomString5}.${extension}`;
|
||||
}
|
||||
|
||||
private async scanFileForViruses(filePath, host?: string, port?: number): Promise<void> {
|
||||
// const clamscan = await (new ClamScan().init());
|
||||
const opts: ClamScan.Options = {
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue