Infura IPFS does not work!

I Keep receiving the 404 message but the is NOTHING wrong with my code!
I’m using “http://ipfs.io:5001/api/v0”. and noting is showing up , I m pissed off about this!

Hi @Jassan888, welcome to our community!

Could you share an example of a full URL that returns a 404 error? Are you seeing this error when trying to access the file in your browser, or through code?

The error is in the browser. My frontend is nextjs so all of it is running in test off of url:http port3000. If that makes any sense

Hey, this doesn’t look like the Infura api, take a look here: HTTP API methods - Infura Docs

Hello this is for a blockchain NFT project. Do I still need to install python in the command prompt for it to work?
Here is the full up load code.

import { create as ipfsHttpClient } from ‘ipfs-http-client’
import { useRouter } from ‘next/router’
import Web3Modal from ‘web3modal’

const client = ipfsHttpClient(‘https://ipfs.infura.io:5001/api/v0’)

import {
marketplaceAddress
} from ‘…/config’

import NFTMarketplace from ‘…/artifacts/contracts/NFTMarketplace.sol/NFTMarketplace.json’

export default function CreateItem() {
const [fileUrl, setFileUrl] = useState(null)
const [formInput, updateFormInput] = useState({ price: ‘’, name: ‘’, description: ‘’ })
const router = useRouter()

async function onChange(e) {
const file = e.target.files[0]
try {
const added = await client.add(
file,
{
progress: (prog) => console.log(received: ${prog})
}
)
const url = https://ipfs.infura.io/ipfs/${added.path}
setFileUrl(url)
} catch (error) {
console.log('Error uploading file: ', error)
}
}
async function uploadToIPFS() {
const { name, description, price } = formInput
if (!name || !description || !price || !fileUrl) return
/* first, upload to IPFS /
const data = JSON.stringify({
name, description, image: fileUrl
})
try {
const added = await client.add(data)
const url = https://ipfs.infura.io/ipfs/${added.path}
/
after file is uploaded to IPFS, return the URL to use it in the transaction */
return url
} catch (error) {
console.log('Error uploading file: ', error)
}
}

This is way more confusing.

@Jassan888 You should run the ipfs-http-client library using node by executing your file name in your terminal with: node [filename].js

Please also check the installation guide for IPFS HTTP Client

@Flaviu can you please give me an example of how to run ipfs http client?
Thank You.

@Jassan888 Please follow the steps below:

  1. Install ipfs-http-client using NPM: npm install --save ipfs-http-client
  2. Create a file < name >.js
  3. Add the following content in the file

const {ipfsClient, globSource, create} = require(‘ipfs-http-client’)

const projectId = ‘YOUR_INFURA_PROJECT_ID’;
const projectSecret = ‘YOUR_INFURA_PROJECT_SECRET’;
async function addFile(){
const auth =
'Basic ’ + Buffer.from(projectId + “:” + projectSecret).toString(‘base64’)

const client = await create({
    host: 'ipfs.infura.io',
    port: 5001,
    protocol: 'https',
    headers: {
      authorization: auth
    }
  })

  for await (const file of client.addAll(globSource("image0.jpeg", "**/*"))) {
    console.log(file)
  }

}

addFile()

  1. Run the file using node: node < filename >.js
  2. Check the terminal output.

Please let me know if you have any other questions