mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-18 13:46:41 +02:00
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:
parent
b23390c880
commit
b41c5eb05d
18
src/sync.d
18
src/sync.d
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue