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

Not saving to home folder (~) under Linux #369

Closed
sansjunk opened this issue Jul 26, 2016 · 3 comments
Closed

Not saving to home folder (~) under Linux #369

sansjunk opened this issue Jul 26, 2016 · 3 comments

Comments

@sansjunk
Copy link

var multer = require('multer');
var upload = multer({
  // dest: '~/uploads/' --> Does not  work
  dest: '/home/santosh/uploads/' // --> Works
});

Multer actually ends up creating a folder named "~" under the app root folder.

@LinusU
Copy link
Member

LinusU commented Jul 27, 2016

This is expected behaviour and is how all other fs-functions work in Node.js.

Can I recommend you to use the untildify package to solve this?

const multer = require('multer')
const untildify = require('untildify')

const upload = multer({
  dest: untildify('~/uploads')
})

// ...

@sansjunk
Copy link
Author

@LinusU thanks. I was not aware of that.

@jpfluger
Copy link
Contributor

For more info...

See this discussion which contains links to even more discussions.

Also, untildify references the home dir that will replace the tilde via the os module.

const os = require('os');
const home = os.homedir();

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

3 participants