ethanent / phin

Node HTTP client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can we send file with phin?

Dobby85 opened this issue · comments

Hi,

I'm trying sending a file with phin but without results. I tried in data of in form, nothing works.
Is there a way to send a file with phin? If yes, how can we do it?

Thanks,

Maxime

Did somenone has a solution? @ethanent

Thanks,

Maxime

commented

Hi! To send a file, simply set the body of your request to the file data like so...

const fileBuffer = fs.readFileSync(path.join(__dirname, 'myfile.png'))

await p({
   'url': 'https://ethanent.me/nonexistentEndpoint',
   'method': 'POST',
   'data': fileBuffer
})