0

I need the users to be able to upload attachments. then i need to display the attachment so it can be selected and viewed.

sometimes there may only be a single attachment. sometimes multiple.

file type can be .xlsx,.xls,.doc, .docx,.ppt, .pptx,.txt,.pdf,.png, .jpg, .jpeg,.gif, .msg

right now im using this line of code in our react/typescript project

faqList.items.getById(addedFaq.data.Id).attachmentFiles.add(attachmentFiles![i].name, 'File added')

it currently uploads a single file (and i need to be able to upload multiple files). and when the file is retrieved and opened. it displays "File added". which is the text added at the end of the code snippet above.

So Im doing something wrong.

So can someone write an example of the proper code needed to upload multiple attachments to a sharepoint list and to retrieve those attachments without them being overwritten?

UPDATE: in the the documentation PNPJS ATTACHMENT DOCS In the example to add an attachment they use the following code

await item.attachmentFiles.add("file2.txt", "Here is my content");

But what is "Here is my content", what does that represent?

  • Working with attachments using pnpjs seems to be pretty well documented (with examples etc): https://pnp.github.io/pnpjs/sp/attachments/ Have you encountered some issue? – Nikolay Nov 05 '22 at 19:36
  • it shows how to add an attachment, but not how to add multiple attachments? Is sharepoint expecting an array of objects for multiple attachments? – some_new_dev_dude Nov 05 '22 at 19:39
  • 1
    Maybe this: https://github.com/pnp/pnpjs/issues/2230 (basically they recommend adding multiple one-by-one) – Nikolay Nov 05 '22 at 19:42

0 Answers0