Beispiel #1
0
 /**
  * Process a file and store it
  **/
 public function store($file)
 {
     // Throw error if no file
     if (empty($file)) {
         throw new Exception("No file was selected");
     }
     $this->title = strtolower($file->getClientOriginalName());
     $this->content = \File::get($file->getRealPath());
     $hashing = array();
     $hashing["project"] = $this->project;
     $hashing["content"] = $this->content;
     $this->hash = md5(serialize($hashing));
     $this->size = $file->getSize();
     $this->filetype = $file->getMimeType();
     // see if there are any crowdsourcing results in the file
     if (preg_match("/^\"HITId\",\"HITTypeId\"/", $this->content) || preg_match("/^_unit_id,_created_at/", $this->content)) {
         $this->results = true;
     }
     // Throw error if file is of wrong type
     if (!in_array($this->filetype, $this->types)) {
         throw new Exception($this->title . " is not of an accepted file type:" . $this->filetype);
     }
     // Throw error if file is too large
     if ($this->size > 90000000) {
         throw new Exception($this->title . " is too large");
     }
 }
 /**
  * Return view for selecting a document for preprocessing.
  */
 public function getIndex()
 {
     $files = File::get();
     $thisUser = \Auth::user();
     foreach ($files as $ent) {
         $hasPermission = PermissionHandler::checkProject($thisUser, $ent['project'], Permissions::PROJECT_WRITE);
         $ent['canWrite'] = $hasPermission;
     }
     if (count($files) > 0) {
         return View::make('media.preprocess.text.pages.actions', compact('files'));
     }
     return Redirect::to('media/upload')->with('flashNotice', 'You have not uploaded any documents yet');
 }