Create an API Key and get Gateway URL
To create an API key, visit the Keys Page and click the “New Key” button in the top right. Once you do that you can select if you want your key to be admin or if you want to scope the privileges of the keys to certain endpoints or limit the number of uses. Make those selections, then give the key a name at the bottom, and click create key.If you are just getting started we recommend using Admin privileges, then move
to scope keys as you better understand your needs
The API keys are only shown once, be sure to copy them somewhere safe!
Startup Remix Project
We can start a Remix app by entering the command below into the terminalcd into the project and install the pinata SDK.
.env file in the root of the project with the following variables:
Setup Pinata
Make a folder in the root of the project calledutils, and inside make a file called pinata.ts with the following code:
Upload Form and Server Action
In theapp/routes directory we can remove the boilerplate code and replace it with the code below.
app/routes/_index.tsx
Form element provided by Remix which lets us make a submission to a server action. The most important piece to notice here is the encType="multipart/form-data", which is crucial to make file / multipart requests work in Remix!
Then we have our server action:
formData, get the file attached, and then we upload it to Pinata using pinata.upload.public.file(). From that method we deconstruct the result and return the cid which we can use in convert. This will make a URL we can return to the client and make accessible to the user, and in our case the <a> tag that links to the content.