mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08: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:
parent
7ccae7c9b2
commit
23eba33613
|
@ -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: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue