mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-02 07:01:30 -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,
|
||||
mimeType?: string,
|
||||
): Promise<IBinaryData> {
|
||||
let fileExtension: string | undefined;
|
||||
if (!mimeType) {
|
||||
// If no mime type is given figure it out
|
||||
|
||||
|
@ -825,6 +826,7 @@ export async function prepareBinaryData(
|
|||
const fileTypeData = await fromBuffer(binaryData);
|
||||
if (fileTypeData) {
|
||||
mimeType = fileTypeData.mime;
|
||||
fileExtension = fileTypeData.ext;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -836,6 +838,7 @@ export async function prepareBinaryData(
|
|||
|
||||
const returnData: IBinaryData = {
|
||||
mimeType,
|
||||
fileExtension,
|
||||
data: '',
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue