🔀 Merge branch 'binary-file-path' of https://github.com/lublak/n8n into lublak-binary-file-path

This commit is contained in:
Jan Oberhauser 2021-03-18 13:20:26 +01:00
commit d65e8ee73b
4 changed files with 7 additions and 3 deletions

View file

@ -103,6 +103,7 @@ export async function prepareBinaryData(binaryData: Buffer, filePath?: string, m
const filePathParts = path.parse(filePath as string);
returnData.dir = filePathParts.dir;
returnData.fileName = filePathParts.base;
// Remove the dot

View file

@ -157,6 +157,10 @@
<div class="label">File Name: </div>
<div class="value">{{binaryData.fileName}}</div>
</div>
<div v-if="binaryData.dir">
<div class="label">Directory: </div>
<div class="value">{{binaryData.dir}}</div>
</div>
<div v-if="binaryData.fileExtension">
<div class="label">File Extension:</div>
<div class="value">{{binaryData.fileExtension}}</div>

View file

@ -60,14 +60,12 @@ export class ReadBinaryFiles implements INodeType {
const items: INodeExecutionData[] = [];
let item: INodeExecutionData;
let data: Buffer;
let fileName: string;
for (const filePath of files) {
data = await fsReadFileAsync(filePath) as Buffer;
fileName = path.parse(filePath).base;
item = {
binary: {
[dataPropertyName]: await this.helpers.prepareBinaryData(data, fileName),
[dataPropertyName]: await this.helpers.prepareBinaryData(data, filePath),
},
json: {},
};

View file

@ -9,6 +9,7 @@ export interface IBinaryData {
data: string;
mimeType: string;
fileName?: string;
dir?: string;
fileExtension?: string;
}