mirror of
https://github.com/versia-pub/server.git
synced 2026-04-27 20:59:15 +02:00
refactor: ♻️ Rewrite media management code
This commit is contained in:
parent
d09f74e58a
commit
faf829437d
34 changed files with 1195 additions and 904 deletions
20
classes/media/media-hasher.ts
Normal file
20
classes/media/media-hasher.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* @packageDocumentation
|
||||
* @module MediaManager/Utils
|
||||
*/
|
||||
|
||||
/**
|
||||
* Utility class for hashing media files.
|
||||
*/
|
||||
export class MediaHasher {
|
||||
/**
|
||||
* Generates a SHA-256 hash for a given file.
|
||||
* @param file - The file to hash.
|
||||
* @returns A promise that resolves to the SHA-256 hash of the file in hex format.
|
||||
*/
|
||||
public async getMediaHash(file: File): Promise<string> {
|
||||
const arrayBuffer = await file.arrayBuffer();
|
||||
const hash = new Bun.SHA256().update(arrayBuffer).digest("hex");
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue