Skip to content

how do I get the Files/Images in my Next.js project? #34

Closed Answered by stevedylandev
Boby900 asked this question in Q&A
Discussion options

You must be logged in to vote

Great question! If you're using the Files API all files are by default private, so in order to access them you need to create a signed URL. You can do this using the cid from the file upload like so:

import { PinataSDK } from "pinata";

const pinata = new PinataSDK({
  pinataJwt: process.env.PINATA_JWT!,
  pinataGateway: "example-gateway.mypinata.cloud",
});

const url = await pinata.gateways.createSignedURL({
	cid: "bafkreib4pqtikzdjlj4zigobmd63lig7u6oxlug24snlr6atjlmlza45dq",
	expires: 30, // Number of seconds link is valid for
});

Alternatively, if you want the file to be publicly accessible, you can do the following:

  1. Create a public Group
import { PinataSDK } from "pinata";

const p…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by stevedylandev
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants