Moodle 3.9.6 / PHP 7.4
Hello,
I've set up onedrive as a repository to use for file submissions on assignments. And it's mainly working fine except, if I try and upload anything over 250MB it fails.
The logs point to this function, and when I've outputted the data, it seems to be the error/lack of response from onedrive returning 'error' here:
$response = $curlinstance->put($created->uploadUrl, $options);
returns: {"error":{"code":"invalidRequest","message":"Invalid request"}}
/repository/onedrive/lib.php
protected function upload_file(\repository_onedrive\rest $service, \curl $curl, \curl $authcurl, $filepath, $mimetype, $parentid, $filename) {
// If that fails, try an upload with the auth headers (will work for work onedrive accounts).
$curls = [$curl, $authcurl];
$response = null;
foreach ($curls as $curlinstance) {
$curlinstance->setHeader('Content-type: ' . $mimetype);
$size = filesize($filepath);
$curlinstance->setHeader('Content-Range: bytes 0-' . ($size - 1) . '/' . $size);
$response = $curlinstance->put($created->uploadUrl, $options);
if ($curlinstance->errno == 0) {
$response = json_decode($response);
} .......
if (empty($response->id)) {
$details = 'File not created';
throw new repository_exception('errorwhilecommunicatingwith', 'repository', '', $details);
}
}
return $response->id;
}
Like I saw, under 250MB there is a valid response:
{"@odata.context":"...... ","@content.downloadUrl":"longstring &ApiVersion=2.0","createdBy":{"application":{"id":"973f7419-4dd0-48a7-b2c2-2a73121a696e","displayName":"vledev2122"},"user":{"email":"S....@lcm.ac.uk","id":"....","displayName":"Lewis, Simon"}},"createdDateTime":"2021-06-25T13:34:49Z","eTag":"\"{5977D4B5-9856-488B-B45A-3D706D4A7669},3\"","id":".....J","lastModifiedBy":{"application":{"id":"973f7419-4dd0-48a7-b2c2-2a73121a696e","displayName":"vledev2122"},"user":{"email":".....@lcm.ac.uk","id":".....","displayName":"Lewis, Simon"}},"lastModifiedDateTime":"2021-06-25T13:34:50Z","name":"myportfolio1-2.zip","parentReference":{"driveId":".....","driveType":"business","id":"0....","path":"....._id_1372/Assignment+onedrive+ass+-+1st+dec_id_116678/assignsubmission_file/submission_files/154785"},"webUrl":"...","cTag":"\"c:{.69},2\"","file":{"hashes":{"quickXorHash":"..."},"irmEnabled":false,"mimeType":"application/zip"},"fileSystemInfo":{"createdDateTime":"2021-06-25T13:34:49Z","lastModifiedDateTime":"2021-06-25T13:34:50Z"},"size":509993} [] []
Our PHP max file upload is 2G.
Is there a file submission limit for onedrive? I can't find one anywhere and not sure if the issue is within moodle or one drive settings. Or is there a size limit for cURL?
thanks in advance,
Simon