Hello, I have a requirement to send a group of attachments to DeepL for translation. I used a loop, and the name of the binary is dynamic. I cannot know how many attachments there are each time the script runs, so I need to use {{$input.item.binary}} or the extracted fileName for passing the value. However, when I use the variable, it always prompts an error: “The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined.” What expression should I use to correctly tell the HTTP request the binary file name? Thank you for your guidance!
Yes, I can use data_0, but when the workflow runs, the number of attachments is not fixed, and sometimes I don’t know how many attachments need to be processed, but I need to request each attachment separately. So I need to use variable names in the http node. When I use the variable name, I get an error.
I have not looked at the deepl documentation yet, but do you need to make a http call per attachment? Or do you need to submit all files in a single http call?
Oh ok great then this should be fairly easy. So does your binaries have names like data_0, data_1, etc? It looks like in the code block you are handling them correct by getting the Object.keys. I would maybe recommend using the Loop node. Once you have your binaries split out into an array, enter the Loop node and then put your http node inside there. This way you can easily manipulate each binary by getting each files properties for calling the http node
我使用了{{ $json.fileName }}、{{$item.binary.data_0.fileName}}、{{Object.keys($binary).split(‘,’)}}但是都报错“The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined.”
I think I fixed the issue, and under my debugging I found out that it was my file that was problematic and it was written correctly, just that my file was faulty and caused the error. I made a mistake in the previous node to modify the file name and the file was unavailable.