Example #1
0
 /**
  * Download S3 files to moodle
  *
  * @param string $filepath
  * @param string $file The file path in moodle
  * @return array The local stored path
  */
 public function get_file($filepath, $file = '')
 {
     list($bucket, $uri) = $this->explode_path($filepath);
     $path = $this->prepare_file($file);
     // OVERWRITE 5: insert
     global $CFG;
     $user_storage = new GcrUserStorageAccessS3();
     $bucket = $user_storage->getBucket();
     if (!$user_storage->authorizeAccess($filepath)) {
         $CFG->current_app->gcError('User does not have permission to access bucket ' . $bucket . ', file: ' . $file, 'gcpageaccessdenied');
     }
     // END OVERWRITE 5
     try {
         $this->s->getObject($bucket, $uri, $path);
     } catch (S3Exception $e) {
         throw new moodle_exception('errorwhilecommunicatingwith', 'repository', '', $this->get_name());
     }
     return array('path' => $path);
 }