Sunday, 4 June 2017

Not work createWriteStream and absolute path

I have 1 issue. Don't understand how it works.

I want create file within fs.createWriteStream and so works only with relative path. All folders was created

let p = path.resolve(`../uploads/${data.id}/${file.originalname}`).toString()

outStream = fs.createWriteStream(`./uploads/example.txt`,{flags:'w'}) //work
outStream = fs.createWriteStream(`${__dirname}/uploads/2/example.txt`,{flags:'w'}) //not work

outStream = fs.createWriteStream(p,{flags:'w'}) //not work

ENOENT: no such file or directory, open '/Users/arsenkarapetan/Documents/sedalina/server/uploads/2/example.txt'

How it do correct? Maybe i don't have permission?



via Arsen Karapetjan

No comments:

Post a Comment