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?

3
  • Working with attachments using pnpjs seems to be pretty well documented (with examples etc): pnp.github.io/pnpjs/sp/attachments Have you encountered some issue? Commented Nov 5, 2022 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? Commented Nov 5, 2022 at 19:39
  • 1
    Maybe this: github.com/pnp/pnpjs/issues/2230 (basically they recommend adding multiple one-by-one) Commented Nov 5, 2022 at 19:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.