Ipfs-path is required error

Hello,
I am trying to upload files to infura ipfs. I am using node js and this is my code:

var file = req.files['file'][0];

    const options = {
        host: 'ipfs.infura.io',
        port: 5001,
        path: '/api/v0/pin/add',
        method: 'POST',
        auth: projectId + ':' + projectSecret,
        file: file,
    };

    let request = https.request(options, (resp) => {
        let body = '';
        resp.on('data', function (chunk) {
            body += chunk;
        });
        resp.on('end', function () {
            console.log(body);
        });
    });
    request.end();

However i get the following error: “ipfs-path is required”. How can I fix this?

1 Like

Hi @Petar_Vitanov, can you say what JavaScript package you are using? It’s hard to pattern match the code onto the myriad of options out there. Is it this one: request - npm

Chris

1 Like