Skip to content

Is there a way to upload files directly from frontend to pinata cloud? #39

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

You must be logged in to vote

Hey there! Yes absolutely! If you take a look at the Next.js quickstart or our uploading files doc we show how you can upload from the client side in a secure fashion. The TL;DR is you can issue a temporary JWT using the keys method on your SDK from your server and send it back to the client for uploading. For example you might have a server endpoint like this:

import { type NextRequest, NextResponse } from "next/server";
import { pinata } from "@/utils/config"; // Import the Pinata SDK instance

export const dynamic = "force-dynamic";

export async function GET() {
  // Handle your auth here to protect the endpoint
  try {
    const uuid = crypto.randomUUID();
    const keyData = await p…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by stevedylandev
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