/**
  * Create a link to a file that forces a download
  *
  * @param \TYPO3\CMS\Core\Resource\FileInterface $file
  * @param bool $uriOnly
  * @return string
  */
 public function render(\TYPO3\CMS\Core\Resource\FileInterface $file, $uriOnly = FALSE)
 {
     $queryParameterArray = array('eID' => 'dumpFile', 't' => '');
     if ($file instanceof \TYPO3\CMS\Core\Resource\File) {
         $queryParameterArray['f'] = $file->getUid();
         $queryParameterArray['t'] = 'f';
     } elseif ($file instanceof \TYPO3\CMS\Core\Resource\ProcessedFile) {
         $queryParameterArray['p'] = $file->getUid();
         $queryParameterArray['t'] = 'p';
     }
     $queryParameterArray['token'] = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac(implode('|', $queryParameterArray), 'resourceStorageDumpFile');
     $queryParameterArray['download'] = '';
     $uri = 'index.php?' . str_replace('+', '%20', http_build_query($queryParameterArray));
     // Add absRefPrefix
     if (!empty($GLOBALS['TSFE'])) {
         $uri = $GLOBALS['TSFE']->absRefPrefix . $uri;
     }
     if ($uriOnly) {
         return $uri;
     }
     $this->tag->addAttribute('href', $uri);
     $this->tag->setContent($this->renderChildren());
     $this->tag->forceClosingTag(TRUE);
     return $this->tag->render();
 }
 /**
  * Generate public url for file
  *
  * @param Resource\ResourceStorage $storage
  * @param Resource\Driver\DriverInterface $driver
  * @param Resource\FileInterface $file
  * @param $relativeToCurrentScript
  * @param array $urlData
  * @return void
  */
 public function generatePublicUrl(Resource\ResourceStorage $storage, Resource\Driver\DriverInterface $driver, Resource\FileInterface $file, $relativeToCurrentScript, array $urlData)
 {
     // We only render special links for non-public files
     if ($this->enabled && !$storage->isPublic()) {
         $queryParameterArray = array('eID' => 'dumpFile', 't' => '');
         if ($file instanceof Resource\File) {
             $queryParameterArray['f'] = $file->getUid();
             $queryParameterArray['t'] = 'f';
         } elseif ($file instanceof Resource\ProcessedFile) {
             $queryParameterArray['p'] = $file->getUid();
             $queryParameterArray['t'] = 'p';
         }
         $queryParameterArray['token'] = GeneralUtility::hmac(implode('|', $queryParameterArray), 'BeResourceStorageDumpFile');
         // $urlData['publicUrl'] is passed by reference, so we can change that here and the value will be taken into account
         $urlData['publicUrl'] = BackendUtility::getAjaxUrl('FalSecuredownload::publicUrl', $queryParameterArray);
     }
 }
 public function populateMetadata(\TYPO3\CMS\Core\Resource\FileInterface $file, \TYPO3\CMS\Core\Resource\Folder $folder)
 {
     $qualities = GeneralUtility::makeInstance(CalculateService::class)->quality($file->getUid());
     $message = '';
     foreach ($qualities as $key => $value) {
         $message .= $key . ' => ' . $value . "\n";
     }
     $this->flash($message);
 }
 /**
  * @param \TYPO3\CMS\Core\Resource\File|\TYPO3\CMS\Core\Resource\FileInterface $file
  * @param string $taskType The task that should be executed on the file
  * @param array $configuration
  *
  * @return ProcessedFile
  */
 public function findOneByOriginalFileAndTaskTypeAndConfiguration(FileInterface $file, $taskType, array $configuration)
 {
     $databaseRow = $this->databaseConnection->exec_SELECTgetSingleRow('*', $this->table, 'original=' . (int) $file->getUid() . ' AND task_type=' . $this->databaseConnection->fullQuoteStr($taskType, $this->table) . ' AND configurationsha1=' . $this->databaseConnection->fullQuoteStr(sha1(serialize($configuration)), $this->table));
     if (is_array($databaseRow)) {
         $processedFile = $this->createDomainObject($databaseRow);
     } else {
         $processedFile = $this->createNewProcessedFileObject($file, $taskType, $configuration);
     }
     return $processedFile;
 }
Exemple #5
0
 /**
  * @param \TYPO3\CMS\Core\Resource\File|\TYPO3\CMS\Core\Resource\FileInterface $file
  * @param string $taskType The task that should be executed on the file
  * @param array $configuration
  *
  * @return ProcessedFile
  */
 public function findOneByOriginalFileAndTaskTypeAndConfiguration(FileInterface $file, $taskType, array $configuration)
 {
     $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table);
     $databaseRow = $queryBuilder->select('*')->from($this->table)->where($queryBuilder->expr()->eq('original', $queryBuilder->createNamedParameter($file->getUid(), \PDO::PARAM_INT)), $queryBuilder->expr()->eq('task_type', $queryBuilder->createNamedParameter($taskType, \PDO::PARAM_STR)), $queryBuilder->expr()->eq('configurationsha1', $queryBuilder->createNamedParameter(sha1(serialize($configuration)), \PDO::PARAM_STR)))->execute()->fetch();
     if (is_array($databaseRow)) {
         $processedFile = $this->createDomainObject($databaseRow);
     } else {
         $processedFile = $this->createNewProcessedFileObject($file, $taskType, $configuration);
     }
     return $processedFile;
 }