0

Im am using PnP nodejs to do certain tasks triggered by SP workflows. To detect whether an uploaded file has changed it's content - I have to retrieve file size or a content hash form the new upload. Unfortunately the item object delivered with ".getItem()" does not provide any hash or file size (with file.Modified it is not possible not reliably detect a file change):

sp.web
  .getFileByServerRelativePath(relativeUrl) //Eg. /Documents/a/file.txt
  .getItem()
  .then((file) => {...})

Any suggestions to retrieve this with PnP?

Or, is there a better and reliable way to detect whether a s specific file has changed on Sharepoint with PnP?

Oscar
  • 59
  • 1
  • 5

1 Answers1

0

You could retrieve the file size use file.Length property, like the below:

  sp.web
    .getFileByServerRelativePath("/sites/test/Shared Documents/a.txt")
    .get()
    .then(file=>{
              console.log(file.Length)
          });
Michael Han
  • 3,475
  • 1
  • 6
  • 8