O
O
Oleg2017-08-02 10:56:15
JavaScript
Oleg, 2017-08-02 10:56:15

How to upload a VKontakte file with a POST request?

I don’t understand a little how to send POST requests from Node.js along with a picture, for example, if I try to upload, I get an empty parameter

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Gromadchuk, 2017-08-03
@LenovDan

const fs = require('fs');
const request = require('request');

const url = 'https://pu.vk.com/c638131/upload.php?_query=eyJhY3QiO...';
const formData = {
    photo: fs.createReadStream('test.jpg'),
};

request.post({url, formData}, (error, httpResponse, body) => {
    if (error) {
        return console.error(error);
    }

    console.log(body);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question