<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ZahidRahman47</title>
    <description>The latest articles on DEV Community by ZahidRahman47 (@zahidrahman47).</description>
    <link>https://dev.to/zahidrahman47</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1378212%2Fb27c582b-9958-4b5b-a58b-8ea53e589c41.jpeg</url>
      <title>DEV Community: ZahidRahman47</title>
      <link>https://dev.to/zahidrahman47</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zahidrahman47"/>
    <language>en</language>
    <item>
      <title>uploading file into pinata</title>
      <dc:creator>ZahidRahman47</dc:creator>
      <pubDate>Sat, 23 Mar 2024 21:34:33 +0000</pubDate>
      <link>https://dev.to/zahidrahman47/uploading-file-into-pinata-22ce</link>
      <guid>https://dev.to/zahidrahman47/uploading-file-into-pinata-22ce</guid>
      <description>&lt;p&gt;hello family. in this function i want to send multiple png,s to pinata using their file upload system and then i want to fetch the images and map it inside my react app here is my code please some one let me know if they already face this issue .&lt;/p&gt;

&lt;p&gt;`const handleImageChange = async () =&amp;gt; {&lt;br&gt;
    setLoaderThree(true);&lt;br&gt;
    try {&lt;br&gt;
      const formData = new FormData();&lt;br&gt;
      const files = Array.from(selectedFile);&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  files.forEach((file) =&amp;gt; {
    console.log(file.name);
    formData.append("file", file);
    formData.append(
      "pinataMetadata",
      JSON.stringify({
        name: file.name,
      })
    );
  });

  formData.append(
    "pinataOptions",
    JSON.stringify({
      cidVersion: 0,
    })
  );

  const res = await fetch(
    "https://api.pinata.cloud/pinning/pinFileToIPFS",
    {
      method: "POST",
      headers: {
        pinata_api_key: `${apikey}`,
        pinata_secret_api_key: `${secretapikey}`,
      },
      body: formData,
    }
  );

  if (res.ok) {
    const resData = await res.json();
    console.log("Parent Hash:", resData.IpfsHash);
    const filesResponse = await fetch(
      `https://gateway.pinata.cloud/ipfs/${resData.IpfsHash}`
    );
    if (filesResponse.ok) {
      const filesText = await filesResponse.text();
      console.log("Response Body:", filesText);
      // Push each image with its corresponding metadata
      files.forEach((file, index) =&amp;gt; {
        setImagesWithMetadata((prev) =&amp;gt; [
          ...prev,
          { imageUrl: filesText, metadata: { name: file.name } },
        ]);
      });
    } else {
      console.error(
        "Failed to retrieve files within the parent hash:",
        filesResponse.statusText
      );
    }
  } else {
    console.error("Failed to pin the file to IPFS");
  }

  setLoaderThree(false);
} catch (error) {
  console.error("Error while processing response:", error);
  setLoaderThree(false);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;};`&lt;/p&gt;

</description>
      <category>pinata</category>
      <category>ipfs</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
