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

ufs.createWriteStream(path) results in Error: ENOENT: no such file or directory, stat #384

Closed
WinstonN opened this issue Dec 20, 2019 · 1 comment

Comments

@WinstonN
Copy link

WinstonN commented Dec 20, 2019

Hi,
I'm trying to create a file, which I want to stream a 115MB file from S3 into but failing horribly. Could you please help me in the right direction?

My code looks like this
The directory does exist and is writable
ufs looks like

ufs
    .use(vol)
    .use(fs)
console.log('test createwritestream ufs')
ufs.createWriteStream('/tmp/ufs.tgz')
if(ufs.existsSync('/tmp/ufs.tgz')) {
  console.log('/tmp/ufs.tgz create success')
}
else {
  console.log('/tmp/ufs.tgz create failed')
}

console.log('test createwritestream fs')
fs.createWriteStream('/tmp/fs.tgz')
if(fs.existsSync('/tmp/fs.tgz')) {
  console.log('/tmp/fs.tgz create success')
}
else {
  console.log('/tmp/ufs.tgz create failed')
}

The result is

2019-12-20T06:49:43.334Z	b1d017eb-a1ea-49d4-8339-c30d07f779a1	INFO	{ Error: ENOENT: no such file or directory, stat '/tmp/ufs.tgz'
    at Object.statSync (fs.js:855:3)
    at Union.createWriteStream (/var/task/node_modules/unionfs/lib/union.js:340:28)
    at Promise (/var/task/src/global/run.js:200:13)
    at new Promise (<anonymous>)
    at downloadFileFromS3 (/var/task/src/global/run.js:181:12)
    at Runtime.module.exports.execute [as handler] (/var/task/src/global/run.js:278:9)
  errno: -2,
  syscall: 'stat',
  code: 'ENOENT',
  path: '/tmp/ufs.tgz' }

The version I am using is:

"unionfs": {
      "version": "4.2.1",
      "resolved": "https://registry.npmjs.org/unionfs/-/unionfs-4.2.1.tgz",
      "integrity": "sha512-QvdUyG3+m3Nh8YQfCV1mzOvBp7izXoEpGMZzqupKrzFY7cWuayKr8JRdN7CwNcNVjXYR2AZBeY+hStPKFUAT+w==",
      "requires": {
        "fs-monkey": "^0.3.3"
      }
    },

Thanks!

@WinstonN
Copy link
Author

nvm
I got this right, by writing the code differently

Using the below works

s3.getObject(params, function(error, data) {
    vol.writeFile(`${ramDisk}/tmp/${fileName}`, data.Body, function(error) {
      // do error checking / validation
    })
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant