remove deprecated method uuid()

This commit is contained in:
OxSaitama 2023-05-11 08:54:08 +02:00
parent 4f1c064189
commit 6904d1be02

View File

@ -6,7 +6,7 @@ import CryptoService from "../CryptoService/CryptoService";
import IpfsService from "../IpfsService/IpfsService"; import IpfsService from "../IpfsService/IpfsService";
import { BackendVariables } from "@Common/config/variables/Variables"; import { BackendVariables } from "@Common/config/variables/Variables";
import { Readable } from "stream"; import { Readable } from "stream";
import { uuid } from "uuidv4"; import { v4 } from "uuid";
@Service() @Service()
export default class FilesService extends BaseService { export default class FilesService extends BaseService {
@ -52,7 +52,7 @@ export default class FilesService extends BaseService {
* @throws {Error} If file cannot be created * @throws {Error} If file cannot be created
*/ */
public async create(file: File, fileData: Express.Multer.File) { public async create(file: File, fileData: Express.Multer.File) {
const key = uuid(); //crypto.getRandomValues(new Uint8Array(16)); const key = v4();
const encryptedFile = await this.cryptoService.encrypt(fileData.buffer, key); const encryptedFile = await this.cryptoService.encrypt(fileData.buffer, key);
//const encryptedFileName = await this.cryptoService.encrypt(Buffer.from(fileData.originalname, 'utf-8'), key); //const encryptedFileName = await this.cryptoService.encrypt(Buffer.from(fileData.originalname, 'utf-8'), key);
const upload = await this.ipfsService.pinFile(Readable.from(encryptedFile), fileData.originalname); const upload = await this.ipfsService.pinFile(Readable.from(encryptedFile), fileData.originalname);