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

"errno":-4058,"code":"ENOENT","syscall":"open" #33

Closed
Umesh2Patel opened this issue Jun 15, 2017 · 4 comments
Closed

"errno":-4058,"code":"ENOENT","syscall":"open" #33

Umesh2Patel opened this issue Jun 15, 2017 · 4 comments

Comments

@Umesh2Patel
Copy link

Umesh2Patel commented Jun 15, 2017

Hi, I am using sampleFile.mv. It was working before but recently I am seeing below exception. I am using Postman tool to make a call. I tried using RestClient tool and seeing same error.

Response:
{
"errno": -4058,
"code": "ENOENT",
"syscall": "open",
"path": "C:\Users\QATools\testdb-api\Users\u000bn0u7yzDesktopOmniture excels files - Copy\omniture-test-data.xlsx"
}

upload api issue

Below is the code i am using:-
var express = require('express')
const fileUpload = require('express-fileupload');
app.post('/uploadfile', function(req, res) {
if (!req.files)
return res.status(400).send('No files were uploaded.');

// The name of the input field (i.e. "sampleFile") is used to retrieve the uploaded file

let sampleFile = req.files.file;
console.log(req.files.file);

var filename = req.files.file['name'];
console.log(filename);
// Use the mv() method to place the file somewhere on your server
sampleFile.mv('C:\Users\user\Desktop\Omniture excels files - Copy/'+filename, function(err) {
if (err)
return res.status(500).send(err);

res.send('File uploaded!');

});
});

@Umesh2Patel Umesh2Patel changed the title I am seeing "errno":-4058,"code":"ENOENT","syscall":"open" "errno":-4058,"code":"ENOENT","syscall":"open" Jun 15, 2017
@richardgirges
Copy link
Owner

Hey @Umesh2Patel can you show me what headers you're sending? Trying to replicate this on my end. Thanks!

@richardgirges
Copy link
Owner

@Umesh2Patel any word? Trying to get more information on what kind of headers you're sending so I can replicate this issue on my end.

@Umesh2Patel
Copy link
Author

Umesh2Patel commented Sep 5, 2017

@richardgirges Thanks for following up. After changing my code I am not seeing the error anymore.
Below is my API. I have added {force:true} and then it started working.

app.post('/deletefiles', function(req, res) {
del(['/app/new-omniture-tests/omniture-tests/omnitureUtilities/*.xlsx'], {force: true}).then(function(paths) {
res.send('Files Deleted! \n ' + paths.join('\n'));
});
});

@thammarith
Copy link

In my case, it turned out that I haven't created the folder uploads/.

If you encounter this, try console.log(path) and make sure that you have that directory created.

const file = req.files.file
const fileName = req.files.file.name
const path = 'uploads/' + fileName

file.mv(path, function(err) {
  if (err) return res.status(500).send(err);
  res.send('File uploaded!');
});

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

3 participants