Skip to content

Microsoft Onedrive fileupload ignores settings filename when binary is selected #22758

@PSinke

Description

@PSinke

Bug Description

When you upload a file to OneDrive the filename from the settings is ignored, and the filename from the binary file itself is used.
I can't currently make a PR for this, but the error is here:

if (operation === 'upload') {
const parentId = this.getNodeParameter('parentId', i) as string;
const isBinaryData = this.getNodeParameter('binaryData', i);
const fileName = this.getNodeParameter('fileName', i) as string;
if (isBinaryData) {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0);
const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
const body = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
let encodedFilename;
if (fileName !== '') {
encodedFilename = encodeURIComponent(fileName);
}
if (binaryData.fileName !== undefined) {
encodedFilename = encodeURIComponent(binaryData.fileName);
}

the encodedFilename var is set from the settings, but then gets overridden if there is a filename in the binary file. I would suggest switching the order of these two if statements. Check for filename in the binary file first , and overwrite if there is a filename set in the settings.

To Reproduce

  1. have a binary file
  2. Upload to Microsoft Onedrive
  3. Set filename in settings, and select 'binary file'
  4. Execute step
  5. Filename on Onedrive has binary file filename, not the settings one

Expected behavior

Expected the filename from the settings to be used when filled out

Debug Info

Not needed. Not an error, just a wrong filename

Operating System

Docker

n8n Version

1.122.4

Node.js Version

unknown

Database

SQLite (default)

Execution mode

main (default)

Hosting

self hosted

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:in-linearIssue or PR is now in Linearstatus:pending-assignmentIssue is waiting for team assignmentstatus:team-assignedA team has been assigned the issue or PRteam:nodesIssue is with the Nodes teamtriage:completeTriage has been completed and issue is ready for internal teams

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions