1.1.6 • Published 10 months ago
public-ipfs-gateway v1.1.6
public-ipfs-gateway
Get Public IPFS gateway url easily.
Install
- Via NPM :
npm i public-ipfs-gateway
- Via Yarn :
yarn add public-ipfs-gateway
Import
- CJS :
const { getAllGateway, getLiveGateway, getAllLiveGateway } = require('public-ipfs-gateway')
- ESM :
import { getAllGateway, getLiveGateway, getAllLiveGateway } from 'public-ipfs-gateway'
A. getAllGateway
import { getAllGateway } from 'public-ipfs-gateway';
// if use commonjs use this :
// const { getAllGateway } = require('public-ipfs-gateway');
// example url
const url = 'ipfs://bafybeiged4aroumss7u646yl5rzq5xawlvni7velqmwgau6jhxqcpgtf44/metamask-wallet.svg';
// example function for test
function test(){
console.log(getAllGateway(url));
}
test();
// result will be like
// [
// 'https://ipfs.io/ipfs/bafybeiged4aroumss7u646yl5rzq5xawlvni7velqmwgau6jhxqcpgtf44/metamask-wallet.svg',
// 'https://cloudflare-ipfs.com/ipfs/bafybeiged4aroumss7u646yl5rzq5xawlvni7velqmwgau6jhxqcpgtf44/metamask-wallet.svg',
// ...
// ]
B. getLiveGateway
import { getLiveGateway } from 'public-ipfs-gateway';
// if use commonjs use this :
// const { getLiveGateway } = require('public-ipfs-gateway');
// example url
const url = 'ipfs://bafybeiged4aroumss7u646yl5rzq5xawlvni7velqmwgau6jhxqcpgtf44/metamask-wallet.svg';
// example function for test
async function test(){
console.log(await getLiveGateway(url));
}
test();
// result will be like
// https://ipfs.io/ipfs/bafybeiged4aroumss7u646yl5rzq5xawlvni7velqmwgau6jhxqcpgtf44/metamask-wallet.svg
Default timeout is 3000ms, you can set custom timeout by add additional param like await getLiveGateway(url, 5000)
.
C. getAllLiveGateway
import { getAllLiveGateway } from 'public-ipfs-gateway';
// if use commonjs use this :
// const { getAllLiveGateway } = require('public-ipfs-gateway');
// example url
const url = 'ipfs://bafybeiged4aroumss7u646yl5rzq5xawlvni7velqmwgau6jhxqcpgtf44/metamask-wallet.svg';
// example function for test
async function test(){
console.log(await getAllLiveGateway(url));
}
test();
// result will be like
// [
// 'https://ipfs.io/ipfs/bafybeiged4aroumss7u646yl5rzq5xawlvni7velqmwgau6jhxqcpgtf44/metamask-wallet.svg',
// 'https://cloudflare-ipfs.com/ipfs/bafybeiged4aroumss7u646yl5rzq5xawlvni7velqmwgau6jhxqcpgtf44/metamask-wallet.svg',
// ...
// ]
Default timeout is 3000ms, you can set custom timeout by add additional param like await getLiveGateway(url, 5000)
.
1.1.6
10 months ago
1.1.5
10 months ago
1.1.4
10 months ago
1.1.3
10 months ago
1.1.2
10 months ago
1.1.1
10 months ago
1.1.0
10 months ago
1.0.10
2 years ago
1.0.9
2 years ago
1.0.8
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago