Set tx hash as image file name in pinata (#17)

Part of https://www.notion.so/Upload-generated-image-to-IPFS-190a6b22d47280f1ba81e860b7ca4ae1

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Reviewed-on: #17
This commit is contained in:
nabarun 2025-02-07 06:05:06 +00:00
parent d3e6f7ad12
commit 3dd1ff74ab
2 changed files with 3 additions and 3 deletions

View File

@ -97,7 +97,7 @@ export async function POST(req: NextRequest): Promise<NextResponse> {
)
}
const pinataResult = await uploadToPinata(imageUrl);
const pinataResult = await uploadToPinata(imageUrl, transactionSignature);
if (pinataResult.error) {
return NextResponse.json(

View File

@ -12,9 +12,9 @@ const pinata = new PinataSDK({
pinataGateway: process.env.PINATA_GATEWAY,
});
export async function uploadToPinata(imageUrl: string): Promise<FluxGenerationResult> {
export async function uploadToPinata(imageUrl: string, transactionSignature: string): Promise<FluxGenerationResult> {
try {
const upload = await pinata.upload.url(imageUrl);
const upload = await pinata.upload.url(imageUrl, { metadata: { name: transactionSignature }});
const publicURL = await pinata.gateways.convert(upload.IpfsHash);