Feature #67111
closedeID=dumpFile - support $asDownload and $alternativeFilename through GPVars
100%
Description
It would be nice if the eID call would support the properties $asDownload and $alternativeFilename like \TYPO3\CMS\Core\Resource::ResourceStorage::dumpFileContents() does. That way we could use a standardized file processor with basic(hmac)/advanced(through hook) validation.
Optional (but nice to have):
Furthermore it would be nice to get the FLOW f:security.csrfToken() viewHelper to build the token or even better get a <a> tag based downloadViewHelper that does the whole stuff.
This viewHelper would ideally have a $asUri property for inline notations e.g. in data attributes and of course the universal tags.
Updated by Frans Saris over 9 years ago
- Status changed from New to Accepted
- Target version changed from 6.2.13 to 7 LTS
That would indeed be a nice feature.
We currently handled it like this https://github.com/beechit/fal_securedownload/blob/master/Classes/Hooks/FileDumpHook.php#L103 but it would better fit in the core.
As this is a feature I set the target to TYPO3 7.
Updated by Vitoandre D'Oria over 9 years ago
Nice! I saw your? code yesterday after discovering the eID=dumpFile and made somethings based on it to test the "download":
<?php
namespace WIRO\WiroBase\ViewHelpers;
/**
* DownloadViewHelper
*/
class DownloadViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper {
/**
* @var string
*/
protected $tagName = 'a';
/**
* Arguments Initialization
*
* @return void
* @see http://docs.typo3.org/typo3cms/ExtbaseFluidBook/8-Fluid/8-developing-a-custom-viewhelper.html#creating-xml-tags-using-tagbasedviewhelper
*/
public function initializeArguments() {
$this->registerUniversalTagAttributes();
}
/**
* Generates a secured download link (unlike getPublicUrl this will always result in a download)
*
* Usage:
* <code>
* {namespace wiroBase=WIRO\WiroBase\ViewHelpers}
*
* <wiroBase:download resourceObject="{model.file.originalResource.originalFile}" title="Download" class="myDownload">
* <div>...</div>
* </wiroBase:download>
*
* <a data-download="{wiroBase:download(resourceObject: '{model.file.originalResource.originalFile}', asUri: 1)}">
* <div>...</div>
* </a>
* </code>
*
* @param TYPO3\CMS\Core\Resource\FileInterface $resourceObject File or ProcessedFile
* @param bool $absolute If set, the URI of the rendered link is absolute
* @param bool $asUri Return a URI instead <a> tags
* @return string Rendered link
* @see \TYPO3\CMS\Core\Resource\ResourceStorage::getPublicUrl()
*/
public function render(\TYPO3\CMS\Core\Resource\FileInterface $resourceObject, $absolute = FALSE, $asUri = FALSE) {
$queryParameterArray = array('eID' => 'dumpFile', 't' => '');
if ($resourceObject instanceof \TYPO3\CMS\Core\Resource\File) {
$queryParameterArray['f'] = $resourceObject->getUid();
$queryParameterArray['t'] = 'f';
} elseif ($resourceObject instanceof \TYPO3\CMS\Core\Resource\ProcessedFile) {
$queryParameterArray['p'] = $resourceObject->getUid();
$queryParameterArray['t'] = 'p';
}
$queryParameterArray['token'] = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac(
implode('|', $queryParameterArray),
'resourceStorageDumpFile'
);
$uriBuilder = $this->controllerContext->getUriBuilder();
$uri = $uriBuilder
->reset()
->setArguments($queryParameterArray)
->setCreateAbsoluteUri($absolute)
->uriFor();
if ($asUri) {
return $uri;
}
$this->tag->addAttribute('href', $uri);
$this->tag->setContent($this->renderChildren());
$this->tag->forceClosingTag(TRUE);
return $this->tag->render();
}
}
The differences are:
- uriBuilder instead http_build_query/TSFE->absRefPrefix
- <a> tag based viewHelper instead External because of the universal tags title, class
The code above still requires the $asDownload Parameter.
A alternative could be to introduce a new path like file.originalResource.publicUrl but instead that file.originalResource.downloadUrl (or publicDownloadUrl). It might not be as flexible as the viewHelper but the usage would be similar at least and it could be used in different contexts (BE,FE)
I am not too familiar with getPublicUrl() does it by default return a absolute or relative URI?
The new function might look like this?:
\TYPO3\CMS\Core\Resource\ResourceStorage::getDownloadUrl(ResourceInterface $resourceObject, $absolute = FALSE)
Questions:
- What should the function return in BE Context if $absolute is set? The url in domain record? Should it work like getPublicUrls: $relativeToCurrentScript = FALSE ? At least in FE context i don't see a need for this??
The second approach is probably more complex because of the different TYPO3_MODE's.
Updated by Benni Mack about 9 years ago
- Target version changed from 7 LTS to 8 LTS
Updated by Riccardo De Contardi over 7 years ago
- Target version changed from 8 LTS to 9.0
Updated by Susanne Moog almost 7 years ago
- Category changed from Frontend to File Abstraction Layer (FAL)
- Target version changed from 9.0 to 9 LTS
Updated by Susanne Moog about 6 years ago
- Target version changed from 9 LTS to Candidate for Major Version
Updated by Gerrit Code Review almost 4 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/67434
Updated by Gerrit Code Review over 3 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66084
Updated by Gerrit Code Review over 3 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66084
Updated by Gerrit Code Review over 3 years ago
Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66084
Updated by Gerrit Code Review over 3 years ago
Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66084
Updated by Gerrit Code Review over 3 years ago
Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66084
Updated by Gerrit Code Review over 3 years ago
Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66084
Updated by Gerrit Code Review over 3 years ago
Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66084
Updated by Gerrit Code Review over 3 years ago
Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66084
Updated by Gerrit Code Review over 3 years ago
Patch set 13 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66084
Updated by Gerrit Code Review over 3 years ago
Patch set 14 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66084
Updated by Gerrit Code Review over 3 years ago
Patch set 15 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66084
Updated by Gerrit Code Review over 3 years ago
Patch set 16 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66084
Updated by Christian Eßl over 3 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 7dda917a7f728b3c3fb3638aafcfcdad591d686f.
Updated by Oliver Bartsch about 3 years ago
- Status changed from Resolved to Closed
Updated by Oliver Bartsch about 3 years ago
- Related to Feature #83285: Support HTML5 "download" attribute in links added
Updated by Georg Ringer 3 months ago
- Related to Feature #100254: File Link Browser: Support `download` attribute added