TYPO3 Logo
secure_downloads
Release: 6.1

Loading data.

  • For Administrators
    • Extension Configuration
    • Regular Expressions
  • For Editors
  • For Developers
    • Events
    • Secured Links
    • Token
    • Security Checks
  • About
    • Changelog
      • Version 6.1.1 - 2024/12/04
      • Version 6.1.0 - 2024/11/27
      • Version 6.0.4 - 2024/09/17
      • Version 6.0.3 - 2024/04/05
      • Version 6.0.2 - 2024/03/22
      • Version 6.0.1 - 2024/01/10
      • Version 6.0.0 - 2023/11/06
      • Version 5.0.3 - 2023/10/27
      • Version 5.0.2 - 2023/06/30
      • Version 5.0.1 - 2023/05/26
      • Version 5.0.0 - 2023/05/05
      • Version 4.1.6 - 2022/12/15
      • Version 4.1.5 - 2022/12/09
      • Version 4.1.4 - 2021/11/09
      • Version 4.1.1 - 2020/06/03
      • Version 4.1.0 - 2020/05/06
      • Version 4.0.0 - 2019/12/03
      • Version 3.0.3 - 2020/05/04
      • Version 3.0.2 - 2019/12/03
      • Version 3.0.1 - 2019/11/20
      • Version 3.0.0 - 2018/11/20
      • Version 2.0.6 - 2018/11/20
      • Version 2.0.5 - 2017/04/20
      • Version 2.0.4 - 2017/04/05
      • Version 2.0.3 - 2016/08/30
      • Version 2.0.2 - 2016/07/22
      • Version 2.0.1 - 2016/07/22
      • Version 2.0.0 - 2016/07/21

Contributors Corner

  • View source of current document
  • How to edit
  • Edit current document on GitHub
  1. Secure Downloads
  2. For Developers
  3. Secured Links
Report issue View source How to edit Edit on GitHub

Secured Links

Following examples clarifies, how to retrieve secured links from different data type sources.

File Object

Instance of \TYPO3\CMS\Core\Resource\File given:

/** @var \TYPO3\CMS\Core\Resource\File $file */
$securedUrl = $file->getPublicUrl();
Copied!

File Reference

Instance of \TYPO3\CMS\Core\Resource\FileReference given:

/** @var \TYPO3\CMS\Core\Resource\FileReference $fileReference */
$securedUrl = $fileReference->getPublicUrl();
Copied!

Fluid Templates

Getting secured links within a fluid template is a no-brainer; you don't have to pay attention to anything here:

<f:image image="{image}" class="img-fluid img-thumbnail" />
<f:image image="{image}" treatIdAsReference="TRUE" class="img-fluid img-thumbnail" />
<img src="{image.publicUrl}" class="img-fluid img-thumbnail" />
Copied!

API

Get a link that is only valid for user 29, with user group 12, is generated on page 89 and expires on 2022/05/08:

$publicUrl = '/fileadmin/secured/invoice.pdf';
$secureDownloadService = GeneralUtility::makeInstance(SecureDownloadService::class);

if ($secureDownloadService->pathShouldBeSecured($publicUrl)) {
    $securedUrl = GeneralUtility::makeInstance(SecureLinkFactory::class)
        ->withResourceUri(rawurlencode($publicUrl))
        ->withUser(29)
        ->withPage(89)
        ->withGroups([12])
        ->withTimeout(1659650400)
        ->getUrl();
}
Copied!
  • Previous
  • Next
Reference to the headline

Copy and freely share the link

This link target has no permanent anchor assigned. You can make a pull request on GitHub to suggest an anchor. The link below can be used, but is prone to change if the page gets moved.

Copy this link into your TYPO3 manual.

  • Home
  • Contact
  • Issues
  • Repository

Last rendered: Dec 04, 2024 12:27

© since 2006 by the authors
  • Legal Notice
  • Privacy Policy