fileHelpers.js
1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Public class exported globally
class FileHelpers {
static getFileExtension(filename) {
return filename.split('.').pop();
}
static getBase64File(b64File) {
return b64File.split(',').pop();
}
static csvIdFilesString(idFiles, idSingleFile) {
if (idFiles == null)
return idSingleFile
else
return idFiles + "," + idSingleFile;
}
static getFileKind(fileKindAttr) {
let fileKind;
if (fileKindAttr == "idCard_front" || fileKindAttr == "idCard_back")
fileKind = "carta_identita";
if (fileKindAttr == "cfCard_front" || fileKindAttr == "cfCard_back")
fileKind = "codice_fiscale";
if (fileKindAttr == "lightBill")
fileKind = "fattura_elettrica"
if (fileKindAttr == "gasBill")
fileKind = "fattura_gas"
/*if (fileKindAttr == "cfCard_front" || fileKindAttr == "cfCard_back")
fileKind = "pec_ricezione"*/
return fileKind;
}
static getSplittedFileListLength(fileListIds){
return fileListIds == null ? 0 : fileListIds.split(",").length;
}
static getLastFileIdForThumbnail(idFile){
return parseInt(idFile.split(',').pop());
}
}
// Export singleton Service Class
export default FileHelpers;