File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 6262$ string ['webfinger_error ' ] = 'Could not get user-information from webfinger service. ' ;
6363$ string ['personal_drive ' ] = 'Personal ' ;
6464$ string ['shares_drive ' ] = 'Shares ' ;
65+ $ string ['exceed_maxbytes_error ' ] = 'File exceeds maximum uploaded file size limit ' ;
Original file line number Diff line number Diff line change @@ -379,10 +379,21 @@ public static function get_instance_option_names() {
379379 * @throws moodle_exception
380380 */
381381 public function get_file ($ fileid , $ filename = '' ): array {
382+ global $ CFG ;
383+
382384 $ localpath = $ this ->prepare_file ($ fileid );
383385 try {
384386 $ file = $ this ->getocismanager ()->get_ocis_client ()->getResourceById ($ fileid );
385- file_put_contents ($ localpath , $ file ->getContentStream ());
387+ if ($ file ->getSize () > (int )$ CFG ->maxbytes && (int )$ CFG ->maxbytes !== 0 ) {
388+ throw new moodle_exception (
389+ 'exceed_maxbytes_error ' ,
390+ 'repository_ocis ' ,
391+ '' ,
392+ null ,
393+ );
394+ } else {
395+ file_put_contents ($ localpath , $ file ->getContentStream ());
396+ }
386397 } catch (HttpException $ e ) {
387398 throw new moodle_exception (
388399 'could_not_connect_error ' ,
You can’t perform that action at this time.
0 commit comments