Rewards of Combining Pinata and IPFS for Secure and Scalable Data Storage

Rewards of Combining Pinata and IPFS for Secure and Scalable Data Storage

Pinata is a web3 media management platform that helps creators and developers share content via IPFS (InterPlanetary File System) with...

Back to top

What is Pinata?

Pinata is a web3 media management platform that helps creators and developers share content via IPFS (InterPlanetary File System) with ease! In addition to simplified file storage, Pinata offers tools to deliver content quickly and create token gated experiences, such as Dedicated Gateways and Submarine.me.

How to Upload to IPFS with Pinata

There are two main ways you can upload files to IPFS with Pinata: the Pinata web app, and the Pinata API.

Pinata Web App

To get started you will want to visit the Pinata website and sign up for a free account, which will give you up to 1GB storage and 100 files!

After you have signed up you can start uploading! Simply press the “Upload” button and select “file”:

Once you have selected the file on your computer, you can give it a name and click “Upload”:

As soon as the file has completed uploading, you should see it listed in your file manager with the name (that you can click on to preview a file) as well as the CID for that file.

Pinata API

If you are building a platform or application and prefer to upload through an API, Pinata has you covered! Be sure to check out the documentation link below, as well as the link to our SDK:

Pinata Docs

Pinata SDK

Here is a quick node.js code snippet showing how you would do a simple file upload to Pinata:

  • Javascript
var axios = require('axios');
var FormData = require('form-data');
var fs = require('fs');
var data = new FormData();
data.append('file', fs.createReadStream('/Users/Desktop/images/cat.JPG'));
data.append('pinataOptions', '{"cidVersion": 1}');
data.append('pinataMetadata', '{"name": "MyFile", "keyvalues": {"company": "Pinata"}}');
var config = {
method: 'post',
url: 'https://api.pinata.cloud/pinning/pinFileToIPFS',
headers: {
'Authorization': 'Bearer PINATA JWT',
…data.getHeaders()
},
data : data
};
const res = await axios(config);
console.log(res.data);

How to View and Retrieve Content from IPFS with Pinata

There are several different ways you can view your content and reference it in a smart contract, including a Protocol URI, Public Gateway, and Dedicated Gateway.

Protocol URI

A standard IPFS URL looks like this:

ipfs://QmRAuxeMnsjPsbwW8LkKtk6Nh6MoqTvyKwP3zwuwJnB2yP

If you copy and paste that into your browser, you may not get anything back. That is because in order to use this one, you need to have a local IPFS node running to participate in the network. Even when you do, it will likely be very very slow since IPFS is still a growing network.

So, why use a Protocol URI? Well for a couple of reasons. If you are building on a blockchain that already uses IPFS a lot, like Ethereum or another L2 chain, lots of marketplaces and apps are used to seeing this format. When they see it, they use tools to convert the URL into a gateway URL so it can display the content on a website. This can be a good thing or a bad thing. If the platform has a dedicated/private gateway, the speed will be very fast (much like our own dedicated gateways). However, if the platform uses a public gateway, the speeds will be very slow.

In the end, the platform has control over how well your content is received. Additionally, using the standard IPFS URL might help future proof your assets, as public gateways might be stopped down the road (however the CID is still in the URL in those cases, so if the platform knows what to do, they can still get the content if pinned).

Public Gateway

A public gateway URL looks something like this:

https://gateway.pinata.cloud/ipfs/QmRAuxeMnsjPsbwW8LkKtk6Nh6MoqTvyKwP3zwuwJnB2yP

This will deliver the content in the browser without the need of a local IPFS node. However, since this gateway is a public gateway, your speed might vary due to the heavy traffic and congestion. Some platforms will see this kind of the URL and switch it out with their own faster gateway choice, but not always. Generally you want to assume that if you take this path, the assets will be slow.

Dedicated Gateway

A dedicated gateway URL looks something like this:

https://pinnieblog.mypinata.cloud/ipfs/QmRAuxeMnsjPsbwW8LkKtk6Nh6MoqTvyKwP3zwuwJnB2yP

Dedicated Gateways are much much faster than any other method, and should ideally be used when trying to display content on your own platform. However, using them in an NFT project should be done in caution. If you use a Dedicated Gateway in your NFT project metadata and image links, your speed will be great, however anytime another marketplace or rarity bot asks the blockchain for the IPFS data, your gateway will be hit. Since most Dedicated Gateways are paid services, this could greatly drive up your costs and usage. You’ll get the best performance, control, and flexibility with this method, however you might have to pay more than the other methods.

Going Further with Pinata

If you want to go to the next level, consider upgrading to the Picnic plan! Not only does this plan give you a Dedicated Gateway, it also gives you access to Submarine.me; a new tool that helps creators make token gated content! You can upload content that is only unlockable by NFT, retweeting, geolocation, and soon debit and credit card payments. Take a look at the demo below!

https://youtu.be/YhT4Xqn1tYI

Connect with us!

Still thirsty for answers? We got them! Check out all the ways you can reach us:

Popular Searches

 What is Staking Crypto  |  CBDC vs Stablecoin  |  What is the Graph  |  CBDC Blockchain  |  Blockchain Vs API  |  What is the Best Software Wallet  |  What is Mastercoin  |  Ethereum Vs Hyperledger Fabric  |  Tangle Vs Blockchain  |  Testnet Vs Mainnet  |  DApps Examples  |  BTC Different From ETH  |  Gas Limit in Blockchain  |  Cryptocurrency Business Model  |  Crypto Faucet Apps  |  Blockchain Vs Quantum Computing  |  Blockchain Layers Explained  |  What is Phishing and How to Prevent it

The Shard

Sign up for The Shard community newsletter

Stay updated on major developments about Shardeum.