Moralis.evmapi.ipfs.uploadFolder parameter error

I am getting the following error when trying to post a file or files to Moralis.EvmApi.ipfs.uploadFolder: [C0005] Request contains unknown parameter: 0. This operation supports the following parameters: abi

I am using nextJS and can verify that my API route has a valid base64 image string. However because i have converted from a blob i don’t have an actual filepath, do i actually need to write my base64 to a filepath before i send it off? (i was just spoofing that with a string based on the image_id right now. Didn’t think that would be required since ipfs really only needs the content.

As of right now i’m just passing an array of objects into the await Moralis.EvmApi.ipfs.uploadFolder function that look like

 {  
        content: imageData,
        path: `${path}.png`
      }

Any help/tips/pointers would be greatly appreciated.

Thanks

this is an example of how upload folder function can be used:

curl --request POST \
     --url 'https://deep-index.moralis.io/api/v2/ipfs/uploadFolder' \
     --header 'accept: application/json' \
     --header 'X-API-Key: API_KEY_HERE' \
     --header 'content-type: application/json' \
     --data '
[
  {
    "path": "moralis/logo.jpg",
    "content": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3"
  }
]
'

you will need a path here, but you can set it to any value that you want

Awesome. Preciate it. That works great. In the event anyone else stumbles upon this… i converted to a fetch…

const uploadToIPFSFolder = async (data) => {
  try {
    const response = await fetch('https://deep-index.moralis.io/api/v2/ipfs/uploadFolder', {
      method: 'POST',
      headers: {
        'Accept': 'application/json',
        'X-API-Key': process.env.MORALIS_API_KEY,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(data)
    });

    const responseData = await response.json();
    console.log('RESPONSE', responseData);
    return responseData;
  } catch (error) {
    console.error('Error:', error);
  }
};
1 Like