How to upload to IPFS using my Infura key

Hello,

I created an IPFS project in Infura and connected a credit card to it.
Currently I am uploading to IPFS using:

const { create } = require(‘ipfs-http-client’)
const client = create(‘https://ipfs.infura.io:5001/api/v0’)
await client.add(
image,
{
progress: (prog) => console.log(...sent: ${prog})
}
)

I am wondering how I can make sure that the upload “uses”/“goes through” my Infura project?

Thanks in advance,
Christof

Hi @Existenziell and welcome to the Infura community!

Have you tried the following before?

const ipfsClient = require('ipfs-http-client');
const projectId = '...';
const projectSecret = '...';
const ipfs = ipfsClient({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' })
const auth = 'Basic ' + Buffer.from(projectId + ':' + projectSecret).toString('base64')

const client = ipfsClient({
  host: 'ipfs.infura.io',
  port: 5001,
  protocol: 'https',
  apiPath: '/api/v0/',
  headers: {
    authorization: auth
  }
})
let result = client.add(buf)
  .then(result => {
    console.log(result);
  });