Update Sharepoint modified file handling for files > 4Mb in size (#594)

* Update Sharepoint modified file handling for files > 4Mb in size
This commit is contained in:
abraunegg 2019-07-17 05:11:38 +10:00 committed by GitHub
parent b23390c880
commit b41c5eb05d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2296,8 +2296,22 @@ final class SyncEngine
// OneDrive SharePoint account modified file upload handling
if (accountType == "documentLibrary"){
// We cant use a session to upload the file, we have to use simpleUploadReplace
response = onedrive.simpleUploadReplace(path, fileDetailsFromOneDrive["parentReference"]["driveId"].str, fileDetailsFromOneDrive["id"].str, fileDetailsFromOneDrive["eTag"].str);
// Depending on the file size, this will depend on how best to handle the modified local file
// as if too large, the following error will be generated by OneDrive:
// HTTP request returned status code 413 (Request Entity Too Large)
// We also cant use a session to upload the file, we have to use simpleUploadReplace
if (getSize(path) <= thresholdFileSize) {
// Upload file via simpleUploadReplace as below threshhold size
response = onedrive.simpleUploadReplace(path, fileDetailsFromOneDrive["parentReference"]["driveId"].str, fileDetailsFromOneDrive["id"].str, fileDetailsFromOneDrive["eTag"].str);
} else {
// Have to upload via a session, however we have to delete the file first otherwise this will generate a 404 error post session upload
// Remove the existing file
onedrive.deleteById(fileDetailsFromOneDrive["parentReference"]["driveId"].str, fileDetailsFromOneDrive["id"].str, fileDetailsFromOneDrive["eTag"].str);
// Upload as a session, as a new file
writeln("");
response = session.upload(path, parent.driveId, parent.id, baseName(path));
}
writeln(" done.");
saveItem(response);
// Due to https://github.com/OneDrive/onedrive-api-docs/issues/935 Microsoft modifies all PDF, MS Office & HTML files with added XML content. It is a 'feature' of SharePoint.