/**
  * Creates a file
  *
  * @param string $job_id
  * @param string $filename
  * @param string $filetype
  * @return string
  * @throws \EventEspressoBatchRequest\Helpers\BatchRequestException
  */
 public function create_file_from_job_with_name($job_id, $filename, $filetype = 'application/ms-excel')
 {
     $filepath = '';
     try {
         $base_folder = $this->get_base_folder();
         $success = $this->_file_helper->ensure_folder_exists_and_is_writable($base_folder . JobHandlerFile::temp_folder_name);
         if ($success) {
             $success = $this->_file_helper->ensure_folder_exists_and_is_writable($base_folder . JobHandlerFile::temp_folder_name . DS . $job_id);
         }
         if ($success) {
             $filepath = $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . $filename;
             $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath);
         }
         //let's add the .htaccess file so safari will open the file properly
         if ($success) {
             $extension = \EEH_File::get_file_extension($filepath);
             \EEH_File::write_to_file($base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . '.htaccess', 'AddType ' . $filetype . ' ' . $extension, '.htaccess');
         }
         //those methods normally fail with an exception, but if not, let's do it
         if (!$success) {
             throw new \EE_Error(__('Could not create temporary file, an unknown error occurred', 'event_espresso'));
         }
     } catch (\EE_Error $e) {
         throw new BatchRequestException(sprintf(__('Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso'), $job_id, $e->getMessage()), 500, $e);
     }
     return $filepath;
 }
 /**
  * Creates a file
  *
  * @param string $job_id
  * @param string $filename
  * @return string
  * @throws BatchRequestException
  */
 public function create_file_from_job_with_name($job_id, $filename)
 {
     $filepath = '';
     try {
         $success = $this->_file_helper->ensure_folder_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR . JobHandlerFile::temp_folder_name);
         if ($success) {
             $success = $this->_file_helper->ensure_folder_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR . JobHandlerFile::temp_folder_name . DS . $job_id);
         }
         if ($success) {
             $filepath = EVENT_ESPRESSO_UPLOAD_DIR . JobHandlerFile::temp_folder_name . DS . $job_id . DS . $filename;
             $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath);
         }
         //those methods normally fail with an exception, but if not, let's do it
         if (!$success) {
             throw new \EE_Error('could_not_create_temp_file', __('An unknown error occurred', 'event_espresso'));
         }
     } catch (\EE_Error $e) {
         throw new BatchRequestException(sprintf(__('Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso'), $job_id, $e->getMessage()), 500, $e);
     }
     return $filepath;
 }