跳至内容

获取二进制数据缓冲区#

二进制数据缓冲区包含工作流处理的所有二进制文件数据。如果您希望对二进制数据执行操作,例如:

  • 操作数据:例如,向CSV文件添加列标题。
  • 在计算中使用数据:例如,基于它计算哈希值。
  • 复杂的HTTP请求:例如,将文件上传与发送其他数据格式相结合。

Python 中不可用

getBinaryDataBuffer() 在使用Python时不支持。

你可以通过n8n的getBinaryDataBuffer()函数访问缓冲区:

1
2
3
4
5
6
/* 
* itemIndex: number. The index of the item in the input data.
* binaryPropertyName: string. The name of the binary property. 
* The default in the Read/Write File From Disk node is 'data'. 
*/
let binaryDataBufferItem = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName);

例如:

1
2
let binaryDataBufferItem = await this.helpers.getBinaryDataBuffer(0, 'data');
// Returns the data in the binary buffer for the first input item

您应始终使用getBinaryDataBuffer()函数,避免直接访问缓冲区的旧方法,例如使用类似items[0].binary.data.data这样的表达式来定位它。