GithubHelp home page GithubHelp logo

wabarc / ipfs-pinner Goto Github PK

View Code? Open in Web Editor NEW
55.0 5.0 16.0 131 KB

A toolkit helps upload files to IPFS pinning services.

License: GNU General Public License v3.0

Go 93.24% Makefile 6.76%
ipfs ipfs-pinner ipfs-pinning-services infura pinata file-sharing web3storage nftstorage nft web3

ipfs-pinner's Introduction

ipfs-pinner

Go Report Card Go Reference Releases ipfs-pinner

ipfs-pinner is a toolkit to help upload files or specific content id to IPFS pinning services.

Supported Golang version: See .github/workflows/testing.yml

Installation

Via Golang package get command

go get -u github.com/wabarc/ipfs-pinner/cmd/ipfs-pinner

Using Snapcraft (on GNU/Linux)

snap install ipfs-pinner

Usage

Supported Pinning Services

Infura is a freemium pinning service that doesn't require any additional setup. It's the default one used. Please bear in mind that Infura is a free service, so there is probably a rate-limiting.

How to enable

Command-line:

Use flag -p infura.

$ ipfs-pinner
A CLI tool for pin files or directory to IPFS.

Usage:

  ipfs-pinner [flags] [path]...

Flags:

  -p string
        Pinner sceret or password.
  -t string
        IPFS pinner, supports pinners: infura, pinata, nftstorage, web3storage. (default "infura")
  -u string
        Pinner apikey or username.

Go package:

import (
        "fmt"

        "github.com/wabarc/ipfs-pinner/pkg/infura"
)

func main() {
        cid, err := infura.PinFile("file-to-path");
        if err != nil {
                fmt.Sprintln(err)
                return
        }
        fmt.Println(cid)
}

or requests with project authentication

import (
        "fmt"

        "github.com/wabarc/ipfs-pinner/pkg/infura"
)

func main() {
        inf := &infura.Infura{ProjectID: "your-project-id", ProjectSecret: "your-project-secret"}
        cid, err := inf.PinFile("file-to-path");
        if err != nil {
                fmt.Sprintln(err)
                return
        }
        fmt.Println(cid)
}

Pinata is another freemium pinning service. It gives you more control over what's uploaded. You can delete, label and add custom metadata. This service requires signup.

Environment variables

Unix*:

IPFS_PINNER_PINATA_API_KEY=<api key>
IPFS_PINNER_PINATA_SECRET_API_KEY=<secret api key>

Windows:

set IPFS_PINNER_PINATA_API_KEY=<api key>
set IPFS_PINNER_PINATA_SECRET_API_KEY=<secret api key>
How to enable

Command-line:

Use flag -p pinata.

ipfs-pinner -p pinata file-to-path

Go package:

import (
        "fmt"

        "github.com/wabarc/ipfs-pinner/pkg/pinata"
)

func main() {
        pnt := pinata.Pinata{Apikey: "your api key", Secret: "your secret key"}
        cid, err := pnt.PinFile("file-to-path");
        if err != nil {
                fmt.Sprintln(err)
                return
        }
        fmt.Println(cid)
}

NFT.Storage is a long-term storage service designed for off-chain NFT data (like metadata, images, and other assets) for up to 31GiB in size. Data is content addressed using IPFS, meaning the URL pointing to a piece of data (“ipfs://…”) is completely unique to that data.

How to enable

Command-line:

Use flag -p nftstorage.

ipfs-pinner -p nftstorage file-to-path

Go package:

import (
        "fmt"

        "github.com/wabarc/ipfs-pinner/pkg/nftstorage"
)

func main() {
        nft := nftstorage.NFTStorage{Apikey: "your api key"}
        cid, err := nft.PinFile("file-to-path");
        if err != nil {
                fmt.Sprintln(err)
                return
        }
        fmt.Println(cid)
}

Web3.Storage is a service to make building on top of Filecoin as simple as possible - giving the developers the power of open, distributed networks via a friendly JS client library. Behind the scenes, Web3.Storage is backed by Filecoin and makes content available via IPFS leveraging the unique properties of each network.

How to enable

Command-line:

Use flag -p web3storage.

ipfs-pinner -p web3storage file-to-path

Go package:

import (
        "fmt"

        "github.com/wabarc/ipfs-pinner/pkg/web3storage"
)

func main() {
        web3 := web3storage.Web3Storage{Apikey: "your api key"}
        cid, err := web3.PinFile("file-to-path");
        if err != nil {
                fmt.Sprintln(err)
                return
        }
        fmt.Println(cid)
}

License

Permissive GPL 3.0 license, see the LICENSE file for details.

ipfs-pinner's People

Contributors

dependabot[bot] avatar waybackarchiver avatar web-flow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ipfs-pinner's Issues

404 authorized(where to set key).

` cid, err := infura.PinHash(hash)

	if err != nil {
		panic(err)
	}

Panic in UploadImageHandler handler; 401 Unauthorized`

Is returning authorized 404. Where do you set the Secret/Project ID?

Thanks!

extremely high ram usage causing os instability

Bug Report

Current Behavior
I compiled the executable for windows amd64 using make on ubuntu linux 22.04.2 LTS amd64
the executable upon loading eats up to 5Gb of RAM for a folder of 1.33Gb of 5 files
i had to stop the process before the system crashed
A previous attempt of uploading 2.9Gb folder 168 files resulted in a crash.

Expected behavior/code
Reasonable RAM usage

Environment

  • Golang version: [e.g. Go 1.20.5]
  • OS: [e.g. Windows 8]
  • RAM 8Gb

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

Permission denied error when using Snapcraft

I'm using POP OS 20.10 (basically Ubuntu 20.10) with ipfs-pinner 0+git.9cf4d45 from snapcraft.

I've got a folder called files with a single txt file which is owned by my user on the system.

When I try to run ipfs-pinner -p pinata ./files/, I get the error open ./files/: permission denied.

Is this a snapcraft quirk with how it's sandboxing works? Any help with debugging this would be very much appreciated. 😁

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.