Convert an IPFS link into one that uses your Dedicated Gateway
Usage
import { PinataSDK } from "pinata-web3";
const pinata = new PinataSDK({
pinataJwt: process.env.PINATA_JWT!,
pinataGateway: "example-gateway.mypinata.cloud",
});
const url = await pinata.gateways.convert(
"ipfs://QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng"
);
Returns
Parameters
url
Accepts CID or IPFS gateway link.
const url = await pinata.gateways.convert(
"bafybeibo5zcqeorhqxczodrx52rn7byyrwfvwthz5dspnjlbkd7zkugefi/hello-1.txt",
);
const url = await pinata.gateways.convert(
"https://ipfs.io/ipfs/bafybeibo5zcqeorhqxczodrx52rn7byyrwfvwthz5dspnjlbkd7zkugefi/hello-1.txt",
);
const url = await pinata.gateways.convert(
"https://bafyreibroegmxohcbvvs3rziqsp3osyn7t5rzot34y6pn5xtewffhtsl4e.ipfs.nftstorage.link/metadata.json",
);
prefix (Optional)
Use a different gateway prefix than the config default
const url = await pinata.gateways.convert(
"QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng",
"https://ipfs.io"
);