๐Ÿช
Web3API.storage (IPFS)
Upload multiple files and place them in a folder directory (ERC1155 Compliant)

๐Ÿ”ฅ uploadFolder (new)

Uploads multiple files and place them in a folder directory. Returns path (asynchronous).

Options:

  • abi(required): Array of JSON and Base64 Supported
JS
React
curl
Unity
1
const options = {
2
abi: [
3
{
4
path: "moralis/logo.jpg",
5
content:
6
"iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3",
7
},
8
],
9
};
10
const path = await Moralis.Web3API.storage.uploadFolder(options);
Copied!
1
import React from "react";
2
import { useMoralisWeb3Api } from "react-moralis";
3
โ€‹
4
const Web3Api = useMoralisWeb3Api();
5
โ€‹
6
const uploadFolder = async () => {
7
const options = {
8
abi: [
9
{
10
path: "moralis/logo.jpg",
11
content:
12
"iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3",
13
},
14
],
15
};
16
const path = await Web3Api.storage.uploadFolder(options);
17
console.log(path);
18
};
Copied!
1
curl -X 'POST' \
2
'https://deep-index.moralis.io/api/v2/ipfs/uploadFolder' \
3
-H 'accept: application/json' \
4
-H 'X-API-Key: MY-API-KEY' \
5
-H 'Content-Type: application/json' \
6
-d '[
7
{
8
"path": "moralis/logo.jpg",
9
"content": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3"
10
}
11
]'
Copied!
1
using MoralisUnity;
2
using MoralisUnity.Web3Api.Models;
3
using System.Collections.Generic;
4
using UnityEngine;
5
โ€‹
6
public class Example
7
{
8
public async void fetchPairReserves()
9
{
10
// Define file information.
11
IpfsFileRequest req = new IpfsFileRequest()
12
{
13
Path = "moralis/logo.jpg",
14
Content = "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3"
15
};
16
// Multiple requests can be sent via a List so define the request list.
17
List<IpfsFileRequest> reqs = new List<IpfsFileRequest>();
18
// Add requests to request list.
19
reqs.Add(req);
20
List<IpfsFile> resp = await Moralis.Web3Api.Storage.UploadFolder(reqs);
21
foreach (IpfsFile file in resp)
22
{
23
Debug.Log(file.ToJson());
24
}
25
}
26
}
Copied!

Example result:

1
[
2
{
3
path: "https://ipfs.moralis.io/QmPQ3YJ3hgfsBzJ1U4MGyV2C1GhDy6MWCENr1qMdMpKVnY/moralis/logo.jpg",
4
},
5
];
Copied!

Tutorial

Legacy UI is present in this video, some things might be slightly different
Bulk Mint NFTs on OpenSea Using IPFS folders (ERC1155 Compliant)