How to use the return value from FilePicker to add to a SharePoint list item attachment, using @pnp

Brass Contributor

I'm getting this error when using the below to submit to a SharePoint list item as an attachment.

234.PNG

I'm using this method:

 

const { filePicked } = this.state;
      
  if (filePicked) {
    let targetList: IList = sp.web.lists.getByTitle('PanelMeetings');
    let selectedFile = filePicked.downloadFileContent();

    let reader = new FileReader();
                   
     reader.readAsArrayBuffer(selectedFile);
        
     reader.onload = () => {
        
           targetList.items.getById(r.data.Id).attachmentFiles.add(filePicked.fileName, reader.result);
       this.setState({
         message: 'Attachment Successfully added'
         });
         };
        }

 

I've read this: https://en.it1352.com/article/fe83588ba22a46fa8c16676cc29ec66a.html But it's not detailing the exact problem comprehensively enough. Can someone tell me what I'm doing wrong here?

 

0 Replies