PinataCloud / Pinata-SDK

Official SDK for the Pinata IPFS service
MIT License
273 stars 67 forks source link

[v2.1.0] `pinFromFS` throws 'EISDIR: illegal operation on a directory, read' #152

Closed aquiladev closed 1 year ago

aquiladev commented 1 year ago

I use sdk "@pinata/sdk": "^2.1.0". The version has issues with pinFromFS. It does not work recursively. When directory has subdirectory, the command throws an error 'EISDIR: illegal operation on a directory, read'. There is a problem with this logic ->

  ...

  const files = await fs.promises.readdir(sourcePath);
  const data = new NodeFormData();
  files.forEach((file: string) => {

      const filepath = path.join(sourcePath, file);
      //for each file stream, we need to include the correct relative file path
      data.append('file', fs.createReadStream(filepath), {
          filepath: normalizePath(filepath)
      });
  });
  ...

SDK version 1.* did handle this properly

rommel-pinata commented 1 year ago

Ok, I just confirmed is an issue, I'll work on this one

willsmillie commented 1 year ago

Hi there, I'm encountering this issue. Downgrading from 2.1.0 to 1.2.1 fixed it... That merge indicates a version 2.1.1, but is not available on NPM.