add api config

This commit is contained in:
Henry
2023-05-04 18:44:51 +01:00
parent 57b8620b93
commit 8d3a374257
18 changed files with 589 additions and 59 deletions
+24
View File
@@ -149,3 +149,27 @@ export const getInputVariables = (paramValue: string): string[] => {
}
return inputVariables
}
/**
* Get blob
* @param {string} fileBase64Str
* @returns {Buffer[]}
*/
export const getBlob = (fileBase64Str: string) => {
let bufferArray: Buffer[] = []
let files: string[] = []
if (fileBase64Str.startsWith('[') && fileBase64Str.endsWith(']')) {
files = JSON.parse(fileBase64Str)
} else {
files = [fileBase64Str]
}
for (const file of files) {
const splitDataURI = file.split(',')
splitDataURI.pop()
const bf = Buffer.from(splitDataURI.pop() || '', 'base64')
bufferArray.push(bf)
}
return bufferArray
}