Sure, you use addAll to add an array of strings, here's a full example:
<!DOCTYPE html>
<html lang="en">
<head><title>js-ipfs minimal add example</title>
<script src="https://cdn.jsdelivr.net/npm/ipfs-core@0.15.2/dist/index.min.js"></script>
<script>
var ipfs;
async function main() {
// Create our IPFS node
ipfs = await window.IpfsCore.create();
// Build our "files" array
const files = [{
content: 'ABC'
},{
content: 'DEF'
}];
// Use ipfs.addAll to add each string as it's own CID, then output the results
for await (const result of ipfs.addAll(files)) {
console.log(result);
}
}
main()
</script>
</head>
</html>
Output:
Object { path: "QmNz1UBzpdd4HfZ3qir3aPiRdX5a93XwTuDNyXRc6PKhWW", cid: {…}, size: 11, mode: 420, mtime: undefined }
Object { path: "QmPF99trksANxfkCExBZt9veeitXEcYLtCiacEoh71Eyx4", cid: {…}, size: 11, mode: 420, mtime: undefined }