koltyakov / gosip

⚡️ SharePoint SDK for Go
https://go.spflow.com
MIT License
145 stars 33 forks source link

Error with AddChunked in Sharepoint Online #51

Closed pnocera closed 2 years ago

pnocera commented 2 years ago

I had an error from Sharepoint Online when adding big documents with the Files().AddChunked(...) method.

After debugging I noticed that the startUpload and continueUpload methods in filesChunked.go try to unmarshal the Sharepoint response into a struct which provides the offset of the current uploading block.

Unfortunately the Sharepoint response doesn't seem to fit the struct defined in filesChunked.go.

I had success with unmarshaling the Sharepoint response into a

  type ChunkResponse struct {
      OdataMetadata string `json:"odata.metadata"`
      Value         string `json:"value"`
  }

the current offset returned being the Value field.

btw thanks for the great work !

PS you can check my implementation at https://github.com/pnocera/gosip/blob/master/api/filesChunked2.go

koltyakov commented 2 years ago

Thanks @pnocera! I'll take a look. This is probably dependent to OData mode. Or maybe a change was introduced to SPO API. As if I'm not mistaken there was also an issue in PnPjs related to chunked upload.

koltyakov commented 2 years ago

@pnocera please try the latest update.

The issue was related to OData mode. It should work now with minimalmetadata and nometadata modes.

Tested in SPO and SP2019.

koltyakov commented 2 years ago

Going to close the issue.