stripe fileUploader in meteor js gives error for the fakepath

走远了吗. 提交于 2019-12-08 09:08:52

问题


I am trying to upload a verification document on stripe upload with below meteor method :

I am passing an object that contains the users identification document to to uploaded on the strip server for verification.

when I write the below method to upload the image file which is a png on the stripe server it gives me an error saying

"Error: ENOENT, no such file or directory 'C:\fakepath\success.png']"

Meteor.methods({
  fileUploader("C:\\fakepath\\success.png"){ // path only for reference purpose
    let fp = fs.readFileSync("C:\\fakepath\\success.
    let StripefileUpload = new Future();
    let file;
    Stripe.fileUploads.create({
      purpose: 'identity_document',
      file: {
        data: fp,
        name: 'success.png',
        type: 'application/octet-stream'
      }
    }, function(err, fileUpload) {
      if (err) {
        console.log(err);
        StripefileUpload.return(err);
      } else {
        file = fileUpload.id;
        console.log(file);
        StripefileUpload.return(file);

      }
    });
    return StripefileUpload.wait();
  }
})

回答1:


Have you tried putting the file somewhere relative to the project? (ie. put it in the working directory?)



来源:https://stackoverflow.com/questions/38596157/stripe-fileuploader-in-meteor-js-gives-error-for-the-fakepath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!