IPFS has traditionally been a fully public network, so anything you pin can be accessed by anyone if they have the CID. While this is a benefit for a majority of blockchain applications, there are still cases where true privacy is needed. This is why Pinata has built Private IPFS, a new service that allows you to keep content private and only share when authorized.
Everything in the SDK and API have been separated by two networks: public and private. This means files and groups will be in separate resources and will be accessed by designating the network in either the SDK method or API route.
// Uploads a file to Public IPFSconst publicUpload = await pinata.upload.public.file(file)// Uploads a file to Private IPFSconst privateUpload = await pinata.upload.private.file(file)
// Create a public groupconst group = await pinata.groups.public.create({ name: "My Public Group",});// Create a private groupconst group = await pinata.groups.private.create({ name: "My Private Group",});
With Public IPFS you can simply access a file through an IPFS Gateway with a CID. Since Private IPFS does not announce to the public IPFS network the only way you can access them is with a temporary access link. This can be generated with either the SDK or the API and set to expire after a designated number of seconds.
Copy
const url = await pinata.gateways.private.createAccessLink({ cid: "bafkreib4pqtikzdjlj4zigobmd63lig7u6oxlug24snlr6atjlmlza45dq", // CID of the file to access expires: 30, // Number of seconds the link is valid for});
Pinata has built several example apps and tutorials you can reference to see how Private IPFS enables token gated experiences in blockchain and crpto contexts.