2

我们使用 TYPO3 Flow 2.3 集成资源对象来上传我们项目中的任何类型的文件。我们File对象中的定义是:

/**
 * @var \TYPO3\Flow\Resource\Resource
 * @ORM\ManyToOne
 */
protected $originalresource;

流畅的调用如下:

<a class="filelink" data-icon="{file.filetype}" href="{f:uri.resource(resource: file.originalresource)}" target="_blank">{file.name}</a>

这个星座中的所有内容都可以正常工作,直到用户上传文件而不以hosts. 服务器Not Found以常规 Apache 错误样式显示。是否支持没有结尾的文件?为什么会这样?

设置是:

TYPO3:
  Flow:  
    resource:
      storages:
        defaultPersistentResourcesStorage:
          storage: 'TYPO3\Flow\Resource\Storage\WritableFileSystemStorage'
          storageOptions:
            path: '%FLOW_PATH_DATA%Persistent/Resources/'
      targets:
        localWebDirectoryPersistentResourcesTarget:
          target: 'TYPO3\Flow\Resource\Target\FileSystemSymlinkTarget'
          targetOptions:
            path: '%FLOW_PATH_WEB%_Resources/Persistent/'
            baseUri: '_Resources/Persistent/'

并且为hosts文件创建的符号链接_Resources/Persistent/用哈希命名,然后是一个没有文件结尾的点,指向实际文件。实际文件存在。

4

1 回答 1

2

这是一个错误,您可以在这里报告:https ://jira.neos.io/

在 Flow 3.x 中,它运行良好,但资源管理发生了重大变化。

在 Web/.htaccess 中添加一行应该可以解决问题,但我不能说这是最好的解决方案。

# Perform rewriting of persistent resource files
RewriteRule ^(_Resources/Persistent/.{40})/.+(\..+) $1$2 [L]

# Add this line - consider security
RewriteRule ^(_Resources/Persistent/.{40})/.+ $1. [L]

并回答为什么会发生 - 默认情况下,持久性资源存储在其中,Data/Persistent/Resources/<hash>并且您有来自 .symlink 的符号链接Web/_Resources/Persistent/<hash>.extension。所以标准符号链接看起来像这样:

0c73666545d393d3d2d6b5a2039dceab56fb3aa2.txt -> /www/FLOW/23/Data/Persistent/Resources/0c73666545d393d3d2d6b5a2039dceab56fb3aa2

如果文件没有扩展名,则末尾只有点

a94a8fe5ccb19ba61c4c0873d391e987982fbbd3. -> /www/FLOW/23/Data/Persistent/Resources/a94a8fe5ccb19ba61c4c0873d391e987982fbbd3

所以实际上 ResourceViewHelper (FileSystemPublishingTarget) 返回的链接是正确的,但是上面的第一个重写规则需要扩展。添加第二个你捕获没有扩展名的文件,只需添加 . 最后将正确的符号链接与哈希和点匹配。

于 2016-03-24T10:38:34.760 回答