nextcloud-link icon indicating copy to clipboard operation
nextcloud-link copied to clipboard

`uploadFromStream` crashes with `createReadStream`

Open maximelafarie opened this issue 2 years ago • 1 comments

In my node project I'm doing the following:

const rs = fs.createReadStream(path.join(config.uploadPathTemp, folderName));

// Create folder recursively
await connector.createRecursiveFolder(path.join(user.target));

// Add files to this folder
await connector.uploadFromStream(path.join(user.target), rs);

The stream is good, the folder exists locally and it waits for being uploaded to NC through nextcloud-link uploadFromStream function. But it throws the following error:

Error:
    at i (/Users/maxime/workspace/my-project/node_modules/nextcloud-link/compiled/client.js:83:35691)
    at ReadStream.t (/Users/maxime/workspace/my-project/node_modules/nextcloud-link/compiled/client.js:83:39772)
    at ReadStream.emit (node:events:394:28)
    at ReadStream.emit (node:domain:470:12)
    at emitErrorNT (node:internal/streams/destroy:193:8)
    at emitErrorCloseNT (node:internal/streams/destroy:158:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  message: [Error: EISDIR: illegal operation on a directory, read] {
    errno: -21,
    code: 'EISDIR',
    syscall: 'read'
  }
}

Am I doing something wrong (do I need to pass some flags to createReadStream?) or is there any stuff related to NC or the lib?

maximelafarie avatar Sep 28 '21 09:09 maximelafarie