Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with fromStdin #72

Closed
partiga-daitan opened this issue Oct 16, 2019 · 1 comment
Closed

Help with fromStdin #72

partiga-daitan opened this issue Oct 16, 2019 · 1 comment
Assignees

Comments

@partiga-daitan
Copy link

partiga-daitan commented Oct 16, 2019

Hello, first of all amazing library!

I'm working in a scenario that it's not desirable to have any files in disc, so I'm trying to use the options "toStdout" and "fromStdin"

I had success using only "toStdout" but loading the data from a file on the disc (helped me a lot) but I'm having problem when combing both options...

This is my code (more or less) ....

        const sevenStream = Seven.extractFull(null, null, {
            $bin: pathTo7zip,
            toStdout: true,
            fromStdin: '',
          });

          const { _childProcess: childProcess } = sevenStream;

          // piping a readableStream that contains the data for a compressed file into childProcess.stdin
          readableStream.pipe(childProcess.stdin);
          
         // here I'm trying to extract the de-compressed information from 
         // childProcess.stdout ...
         // this code works fine if I load the data from a disc file (instead of stdin)
         childProcess.stdout.setEncoding('utf8');

          let chunkHolder = '';

          childProcess.stdout.on('data', (chunk) => {
            console.log(`Received ${chunk.length} bytes of data.`);
            chunkHolder += chunk;
          });

          return childProcess.stdout.on('end', async () => {
            console.log('uploading file from childProcess.stdout...', { uploadPath, inboundBucket });
            await s3.uploadS3Content(chunkHolder, uploadPath, inboundBucket);

            // Delete file from the FTP server
            console.log('deleting FTP file...', { ftpPath });
            await FTP.deleteFile(ftpPath);

            return innerResolve();
          });

@q2s2t q2s2t self-assigned this Oct 27, 2019
@q2s2t q2s2t added the question label Oct 27, 2019
@q2s2t
Copy link
Owner

q2s2t commented Oct 27, 2019

Hi, and thank you for the interest.
I've written a test case that may help you with the fromStdin part. It's in this commit 6a337ad
Let me know if helps !

@q2s2t q2s2t added the stale label Nov 9, 2019
@q2s2t q2s2t closed this as completed Nov 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants