NavigationContentFooter
Jump toSuggest an edit

How to retrieve your pinned content

Reviewed on 03 June 2024Published on 30 May 2023

Retrieving content using a Kubo client

Once your content is pinned on our service, you can retrieve it via any other Kubo client, compatible with Linux, Mac, and Windows.

  1. Run the following CLI command to initialize your local IPFS node:

    ipfs init
  2. Run the following CLI command to launch the IPFS background process, effectively turning your device into a functioning node in the IPFS network:

    ipfs daemon
    Tip

    If you wish to use the same terminal for future commands, you need to run ipfs daemon &. This will run the daemon in the background and return control to the terminal.

  3. Run the following command to fetch your content using its CID and store it in a file. Make sure to replace the example values with your own:

    ipfs get <YOUR_PINNED_CID> > myFile
    Note

    Your content will be stored in a file called myFile.

Retrieving content using an HTTP gateway

There are different ways to access data over the HTTP or HTTPS protocols. You can either use a web browser or the curl command.

Paste the following link into your web browser to retrieve public content via an IPFS gateway. Make sure to replace the example value with your own:

https://ipfs.io/ipfs/<YOUR_PINNED_CID>

Alternatively, run the following curl command to retrieve it via a local client. Also make sure to replace the example value with your own:

curl https://ipfs.io/ipfs/<YOUR_PINNED_CID>

Retrieving content using a Go client

You can also retrieve pinned content via the Go program. To do so, we recommend using the official kubo client rpc.

In this case, you need to run an IPFS node (like Kubo) to perform operations with the IPFS network.

package main
import (
"context"
"fmt"
"os"
"github.com/ipfs/boxo/files"
"github.com/ipfs/kubo/client/rpc"
"github.com/ipfs/kubo/core/commands/cmdutils"
)
func main() {
// Create an IPFS RPC client for the local API
api, err := rpc.NewLocalApi()
if err != nil {
fmt.Println("Error creating IPFS RPC client:", err)
return
}
// CID of the content you want to retrieve
cid := "<YOUR_PINNED_CID>"
// Convert the CID to a path
p, err := cmdutils.PathOrCidPath(cid)
if err != nil {
fmt.Println("Error resolving path:", err)
return
}
// Send get command to ipfs node
ctx := context.Background()
file, err := api.Unixfs().Get(ctx, p)
if err != nil {
fmt.Println("Error getting content:", err)
return
}
// Write the content to the file
err = files.WriteTo(file, "myFile")
if err != nil {
os.Exit(1)
}
// Write the content to the file with cid filename by default
//res := files.ToFile(file)
}
Docs APIScaleway consoleDedibox consoleScaleway LearningScaleway.comPricingBlogCarreer
© 2023-2024 – Scaleway