@tc-libs/file-handler 3.6.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +75 -6
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,11 +1,80 @@
1
- # file-handler
1
+ # @tc-libs/file-handler
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ Layer applicativo sopra `@tc-libs/file` e `@tc-libs/storage` per elaborazione e persistenza file.
4
4
 
5
- ## Building
5
+ Espone:
6
6
 
7
- Run `nx build file-handler` to build the library.
7
+ - `FileHandlerModule`
8
+ - `FileHandlerService`
9
+ - `FileHandlerTextService`
10
+ - `FileHandlerVideoService`
8
11
 
9
- ## Running unit tests
12
+ ## Registrazione
10
13
 
11
- Run `nx test file-handler` to execute the unit tests via [Jest](https://jestjs.io).
14
+ ```ts
15
+ FileHandlerModule.register(
16
+ {
17
+ image: {
18
+ quality: 80,
19
+ },
20
+ resizes: [
21
+ { suffix: 'thumb', width: 256, height: 256 },
22
+ ],
23
+ },
24
+ true,
25
+ );
26
+ ```
27
+
28
+ ## `FileHandlerService`
29
+
30
+ Funzioni principali:
31
+
32
+ - `convertToBytes('10MB')`
33
+ - `handleFile(file, options?)`
34
+ - `handleFiles(files)`
35
+ - `getFileInfo(file)`
36
+ - `hashName(name)`
37
+
38
+ Nel codice attuale il flusso principale implementato riguarda soprattutto le immagini:
39
+
40
+ - upload su storage
41
+ - eventuali resize
42
+ - generazione nome hashato
43
+
44
+ ## `FileHandlerTextService`
45
+
46
+ Permette di estrarre testo da:
47
+
48
+ - plain text
49
+ - ODT
50
+ - PDF
51
+ - DOCX
52
+ - PowerPoint
53
+
54
+ Esempio:
55
+
56
+ ```ts
57
+ const text = await this.fileHandlerTextService.extractText(file);
58
+ ```
59
+
60
+ ## `FileHandlerVideoService`
61
+
62
+ Funzioni principali:
63
+
64
+ - `getDuration(buffer, filename)`
65
+ - `convertToLowQualityAudio(...)`
66
+ - `convertToLowQualityVideo(...)`
67
+ - `generateThumbnail(...)`
68
+
69
+ Richiede ffmpeg/ffprobe disponibili nell'ambiente.
70
+
71
+ ## Nota operativa
72
+
73
+ L'entry service `FileHandlerService` oggi gestisce soprattutto immagini; i rami video/audio nel metodo `handleFile` sono commentati, quindi per quei casi va usato direttamente `FileHandlerVideoService` o estesa la logica.
74
+
75
+ ## Sviluppo
76
+
77
+ ```bash
78
+ nx build file-handler
79
+ nx test file-handler
80
+ ```
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@tc-libs/file-handler",
3
- "version": "3.6.0",
3
+ "version": "3.8.0",
4
4
  "dependencies": {
5
- "@tc-libs/database": "3.6.0",
6
- "@tc-libs/constant": "3.6.0",
7
- "@tc-libs/app-cache": "3.6.0",
8
- "@tc-libs/storage": "3.6.0",
9
- "@tc-libs/file": "3.6.0",
5
+ "@tc-libs/database": "3.8.0",
6
+ "@tc-libs/constant": "3.8.0",
7
+ "@tc-libs/app-cache": "3.8.0",
8
+ "@tc-libs/storage": "3.8.0",
9
+ "@tc-libs/file": "3.8.0",
10
10
  "@nestjs/common": "^11.0.12",
11
11
  "@nestjs/mongoose": "^11.0.3",
12
12
  "mongoose": "^8.13.1",