mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor: Automatically add fileExtension from FileTypeResult to binary data (#3591)
* ♻️ Add fileExtension from FileTypeResult to buffer data * ⚡ Minor improvement Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
@@ -809,6 +809,7 @@ export async function prepareBinaryData(
|
|||||||
filePath?: string,
|
filePath?: string,
|
||||||
mimeType?: string,
|
mimeType?: string,
|
||||||
): Promise<IBinaryData> {
|
): Promise<IBinaryData> {
|
||||||
|
let fileExtension: string | undefined;
|
||||||
if (!mimeType) {
|
if (!mimeType) {
|
||||||
// If no mime type is given figure it out
|
// If no mime type is given figure it out
|
||||||
|
|
||||||
@@ -825,6 +826,7 @@ export async function prepareBinaryData(
|
|||||||
const fileTypeData = await fromBuffer(binaryData);
|
const fileTypeData = await fromBuffer(binaryData);
|
||||||
if (fileTypeData) {
|
if (fileTypeData) {
|
||||||
mimeType = fileTypeData.mime;
|
mimeType = fileTypeData.mime;
|
||||||
|
fileExtension = fileTypeData.ext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -836,6 +838,7 @@ export async function prepareBinaryData(
|
|||||||
|
|
||||||
const returnData: IBinaryData = {
|
const returnData: IBinaryData = {
|
||||||
mimeType,
|
mimeType,
|
||||||
|
fileExtension,
|
||||||
data: '',
|
data: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user