Use as pinning service

How i can add infura as pinning service using IPFS desktop app?

Its requesting and api endpoint and secret access tokeen

Hi @Joangeldelarosa and welcome to the Infura community.

You can register for a free Infura account here: https://infura.io/register
After creating a new account, click create a new project on the top right of the Infura dashboard and create a new ‘IPFS’ Project. This process will create a new IPFS endpoint and give you a secret access token.

Kind regards,
Alex | Infura Support

Thank you @APDAN , already did that but when using IPFS desktop app and adding if says “Failed to fetch”

I already have an account, but i need to add is as a pinned service in IPFS official desktop app because its easiest to upload data from there an pin it, i got many issues when trying to pin it using codes

@Joangeldelarosa I got a second opinion about the error you are running into on IPFS desktop. I also confirmed the same issue by testing remote pinning on my lab machine. I am also getting a failed to fetch message.

I checked in with the team and unfortunately at this moment Infura does not currently support remote pinning services on IPFS desktop. I apologize for any inconveniences this may have caused. I will make sure to send an update if this changes in the future. In the meantime there are alternate pinning services like Pinata, this is the service I am personally using now for my projects on IPFS desktop.

Kind regards,
Alex | Consensys Infura Support

Hello, we are also attempting to use Infura IPFS Remote Pinning Service as Pinata has not worked.

This is becoming a bit confusing so perhaps @APDAN or someone from the team can help?

If we cannot configure the IPFS desktop to use Infura Remote Pinning Service, how can we securely pin the files after they have been uploaded?

In our case we are using client side JS in the browser to upload a file to the Infura IPFS Gateway. This is accomplished using the ipfs-http-client module.

On our backend that runs Node JS is where we see the remote pinning to be implemented.

So the way I have understood this is that:

  1. We must run a local IPFS daemon for this to work
  2. We upload a file to IPFS Gateway
  3. We then remote pin it with the API using the ipfs-http-client again

I can also mention that this is the backend implementation:
const client = ipfsHttpClient({
host: ‘ipfs.infura.io’,
port: 5001,
protocol: ‘https’,
apiPath: ‘/api/v0’,
headers: {
authorization: infuraAuth
}
client.pin.rm(path)

After running these API’s we get the following console output:
IPFS 0.11.0
Path
error - unhandledRejection: HTTPError: not pinned or pinned indirectly

Any thoughts or ideas would be appreciated

Thank you

@comicsaint,

There are multiple ways to securely upload content and pin it simultaneously. The most common method is to do an api call inside a terminal using curl and authenticate our session using the project id and secret. You can also use code on the back end to create an uploading session and upload content and retrieve a hash. All the methods are described here with examples: https://docs.infura.io/infura/networks/ipfs/how-to/make-requests

Another solution is to use the client uploader tool which is easy enough to spin up and to start quickly uploading files: https://blog.infura.io/ipfs-file-upload-client-tool/

I personally use the client uploader tool (link above) or if I need to quickly upload+pin a single file I will use this command in my terminal:

  •    curl "https://ipfs.infura.io:5001/api/v0/add?pin=true" \
    
  •    -X POST \
    
  •    -u "projectid:projectsecret" \
    
  •    -H "Content-Type: multipart/form-data" \
    
  •    -F file=@"/Users/Username/Desktop/test/test.txt"
    

You can also now use the new dedicated gateways feature to view pinned content: https://blog.infura.io/introducing-ipfs-dedicated-gateways/

Let me know if this helps!

Kind regards,
Alex | Infura Support @ Consensys

Hello Alex @APDAN and thank you for the explanation

Let me give you a little background to our use-case

So the creation of files can be done by an authorized person

We are allowing generation of the files via our WebApp. So what we have access to at the moment is the ipfs-http-client which is the preferred method of communicating with IPFS

The person basically uses a web-form to submit and that uploads the files to IPFS. Uploading and pinning at the same time is perhaps not ideal. First we upload an image file, then we upload metadata, then we need to make sure it is not taken offline if the person submitting the files is actually finalizing the transaction. At that point we want to pin it

I guess we could hack it with a regular fetch from the back-end in that case but how would we integrate the front-end in this scenario?

@comicsaint how is your team capturing the hashes? Are you storing them in a database to be pinned later or do you want let the user have a pinning option after all data is already in IPFS in the same session? Do you want that user to have the choice to selectively pin the newly formed hash after generation?

Kind regards,
Alex | Infura Support @ Consensys

@APDAN
Think we can narrow it down to the following three steps?

  1. ipfs-http-client.add which returns the CID
  2. CID is passed to back-end for pinning?
  3. The CID is saved on the blockchain upon successful pin

@comicsaint

If files are going to be interacted with and uploaded from the front end by interacting with the ipfs-http-client I would recommend:

Using the ipfs-http-client.add method to upload files and to return the hash (that would be mapped as a variable) after uploading. When the hash result returns, I would then pin that hash to IPFS. I would then simultaneously interact with a deployed smart contract to map the “pinned hash” in the deployed smart contract.

Example:
Front end:
const ipfsClient = require(‘ipfs-http-client’);
const ipfs = ipfsClient({
host: ‘ipfs.infura.io’,
port: 5001,
protocol: ‘https’,
headers: {
authorization: auth,
}
})
const content = ipfsClient.Buffer.from(’{message: “hello world”}’)
const addResult = await ipfs.add(content)
const hash = addResult[0].hash
console.log(hash)

const pinset = await ipfs.pin.add(hash)
console.log(pinset)

const checkPins = await ipfs.pin.ls(hash)
console.log(checkPins)

For the Smart contract / blockchain portion, I would look at this contract: dvideo.sol This contract and front end application uploads videos to ipfs then registers each hash as an item in a smart contract.

Hope this helps.

Kind regards,
Alex | Infura Support @ Consensys

Thank you Alex @APDAN

But if we run the below in the client config how can auth be secure?
headers: {
authorization: auth,
}

Really feel like the pinning is best done from the back-end to keep things safe but then I first need to add it to the front and then pass it to the back and having that said, we’re back at the previous reply

Warm regards
R

@comicsaint sorry that is just an example, not to be used in production. I am sure there are lots of docs on using dotenv to hide the keys in a .env file, but thats another discussion.

From the front end, you would upload a file to an IPFS gateway or provider. The result will console.log return a hash. We can record that hash in maybe a session state channel like say in react.js then chose to run a pin command on the hash only since the content is already uploaded.

Ok, let’s try to take a step back to see if we can get any closer to a solution

We are using NextJS

We can successfully upload a file to IPFS using the Infura Gateway. This is not an authenticated request because there is no way to secure that request from the client side:
host: ‘ipfs.infura.io’,
port: 5001,
protocol: ‘https’,
apiPath: ‘/api/v0’

The add method on the client returns the .path which is used to retrieve the file from IPFS Infura Gateway configured with the gateway address posted above

The code looks like this:
client.add(file, {
cidVersion: 1,
hashAlg: ‘sha2-256’,
progress: (prog) => console.log(received: ${prog})
})

When this is complete we have to pin the files and this is where we could use some clear instructions for how the Infura Remote Pinning service works. We can pass the CID to the back-end to do whatever is required for pinning it

This is where we can use the ipfs-http-client again with the following config:
const client = ipfsHttpClient({
host: ‘ipfs.infura.io’,
port: 5001,
protocol: ‘https’,
apiPath: ‘/api/v0’,
headers: {
authorization: infuraAuth
}

This time passing the parameters and secrets safely on the back-end

const version = await client.version()
console.log(“IPFS”, version.version)
console.log(“Path”, path)
client.pin.rm(path)

The above code is what produced the output posted in a previous reply:
“After running these API’s we get the following console output:
IPFS 0.11.0
Path
error - unhandledRejection: HTTPError: not pinned or pinned indirectly”

We are obviously doing something wrong in this process, could you try to “pinpoint” the issue and suggest the best approach in our case?

Thank you very much
R

try client.pin.add for pinning. I see that you are using just client.pin

Kind regards,
Alex | Infura Support @ Consensys

Hey Alex @APDAN

I have been trying out this issue for a couple of days now but I am not getting anywhere. At least that’s what it feels like at the moment.

So to summarize, we are getting a 200 status when we work locally but as soon as we run client.pin.add(path) we get the 500 Internal Server Error back. The request takes around 6sec to return [HTTP/2 500 Internal Server Error 5798ms]

How can we debug this issue?

Thank you