1

Here what i am doing ,I am getting the file path from

 var url = JSON.stringify(req.body.path); 

which giving me the correct path but when i am using the passing the url inside the below chunk of code

 fs.createReadStream(url).
    pipe(bucket.openUploadStream('test.apk')).
    on('error', function(error) {
      assert.ifError(error);
    }).
    on('finish', function() {
      console.log('done!');
      res.send("Uploaded Sucessfully..")
      process.exit(0);
    });

};

I am getting below error

Error: ENOENT: no such file or directory, open 'E:\SomeServer\"..\apks\testappV1.0.0.apk"'
at Error (native)

but if i am hard coding

var url1 = '../apks/testappV1.0.0.apk';

the url1 is working perfdect with the above code why url not working i think i am doing some silly mistake not able to find , Can you please point out what i am doing wrong here.

6
  • Try this './../apks/testappV1.0.0.apk' or __dirname+'../apks/testappV1.0.0.apk' Commented Oct 6, 2017 at 6:12
  • None of the above is working ! Commented Oct 6, 2017 at 6:17
  • can you specify your folder structure? Commented Oct 6, 2017 at 6:29
  • 1
    Try not to stringify the path. No JSON.stringify. var url = req.body.path; Commented Oct 6, 2017 at 6:37
  • You are right did small mistake didn't realized you can post your answer . Commented Oct 6, 2017 at 6:47

1 Answer 1

1

No need to stringify the path.No JSON.stringify. req.body.path is already a string.

var url = req.body.path; 

fs.createReadStream(url).
    pipe(bucket.openUploadStream('test.apk')).
    on('error', function(error) {
      assert.ifError(error);
    }).
    on('finish', function() {
      console.log('done!');
      res.send("Uploaded Sucessfully..")
      process.exit(0);
    });

};

Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.