#Satyra1

1 messages · Page 1 of 1 (latest)

elder foxBOT
patent dew
#

Hi there!

mighty kayak
#

while i am trying to const file: Express.Multer.File = req.file;
try {
if (!file) {
return res.json({
error: 'No file to validate bank account provided',
});
} else {
console.log({ file });
const fileContent: string = file.buffer.toString('base64');

  const date = new Date();

  console.log({
    purpose: 'identity_document',
    file: {
      data: fileContent,
      name: `${date.getDate()}`,
      type: file.mimetype,
    },
  });

  const fileStripe = await stripe.files.create({
    purpose: 'identity_document',
    file: {
      data: fileContent,
      name: `${date.getDate()}`,
      type: file.mimetype,
    },
  });
  console.log({ fileStripe });

  return res.json({
    purpose: 'identity_document',
    file: {
      data: fileContent,
      name: `${date.getDate()}`,
      type: file.mimetype,
    },
  });
}

} catch (error: any) {
console.log({ e: error.message });
return res.json({
error: error.message,
});
}

patent dew
mighty kayak
#

req_c7GyAL1faA3Aq3

patent dew
#

Looks like there's an issue with the format of the file you are trying to send, as mentioned in the error message you shared

We don't currently support file type: application/octet-stream. Try uploading a file with one of the following mimetypes: application/pdf, image/jpeg, image/png

mighty kayak
#

Buf file that I'm sending is in JPG or png file

patent dew
mighty kayak
#

But I have to get this file from request from user

#

So I am using multer

patent dew
#

I'm not familiar with multer, sorry. So not sure how to make that work.

mighty kayak
#

with multer i am getting buffered file

#

then i am using this buffer to get base64 string

#

after this everything is the same

golden fog
#

Are you using the same code for stripe.files.create then?

mighty kayak
#

yeah

golden fog
#

Interesting, it sounds like whatever is happening with multer isn't getting it in to the correct format then. Trying to think of how to debug this

#

Can you try doing this with the same file through multer and locally to see if you see any differences in the buffer that it creates?