Advertisement
yarin0600

Untitled

Jan 11th, 2024
980
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const pinFileToIPFS = async () => {
  2.     try {
  3.       const formData = new FormData();
  4.  
  5.       // Convert the image file to a stream
  6.       const imageStream = streamifier.createReadStream(PinnieImage);
  7.  
  8.       // Append the stream to FormData
  9.       formData.append('file', imageStream, { filename: 'Pinnie.png' });
  10.  
  11.       // Now you can use formData for your IPFS request or any other purpose
  12.     } catch (error) {
  13.       console.error('Error pinning file to IPFS:', error);
  14.     }
  15.   };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement