web element – Loading multiple attachments causing 409 conflict error. (SPFX, PNP)

Unfortunately there is no batch API in SP PNP.
However, his task seems to be achievable with the use of the standard Promise.all functionality Yes, there will be numerous physical requests, but the script can be quite simple like:

var itemPnp = $ pnp.sp.web.getList (& # 39; / sites / dev01 / Lists / Custom02 & # 39;). items.getById (101);

promises var = [
  itemPnp.attachmentFiles.add('Attachment 01.txt', 'Content123'),
  itemPnp.attachmentFiles.add('Attachment 02.txt', 'Content234'),
  itemPnp.attachmentFiles.add('Attachment 03.txt', 'Content567'),
  itemPnp.attachmentFiles.add('Attachment 04.txt', 'Content789')
];

Promise.all (promises) .then (function (results) {
console.log (results);
});

You must add files to the series of promises and then use Promise.all and pass on the promise one by one.

You need to do something like this:

leave files = [{
    name: "File5.txt",
    content: "balh"
}, {
    name: "File6.txt",
    content: "balh"
}, {
    name: "File7.txt",
    content: "balh"
}, {
    name: "File8.txt",
    content: "balh"
}]

pnp.sp.web.lists.getByTitle ("ChoiceFieldList"). items.getById (1) .attachmentFiles.addMultiple (files) .then (_ => {

pnp.sp.web.lists.getByTitle ("ChoiceFieldList"). items.getById (1) .attachmentFiles.get (). then (files => {
console.warn (files);
})

});