[英]Are TYPO3 Flow Resources allowed with no ending?
我們使用 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
那樣結束。 服務器以常規的 Apache 錯誤樣式顯示Not Found
。 是否支持沒有結尾的文件? 為什么會發生這種情況?
設置是:
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/'
在_Resources/Persistent/
中為hosts
文件創建的符號鏈接以哈希命名,然后是一個指向實際文件的沒有文件結尾的點。 實際文件存在。
這是一個錯誤,您可以在此處報告: 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>
並且您在那里有來自Web/_Resources/Persistent/<hash>.extension
符號鏈接。 所以標准符號鏈接看起來像這樣:
0c73666545d393d3d2d6b5a2039dceab56fb3aa2.txt -> /www/FLOW/23/Data/Persistent/Resources/0c73666545d393d3d2d6b5a2039dceab56fb3aa2
如果文件沒有擴展名,則末尾只有點
a94a8fe5ccb19ba61c4c0873d391e987982fbbd3. -> /www/FLOW/23/Data/Persistent/Resources/a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
所以實際上ResourceViewHelper(FileSystemPublishingTarget)返回的link是正確的,但是上面的重寫規則首先需要擴展。 添加第二個您可以捕獲沒有擴展名的文件,只需添加 . 最后匹配正確的符號鏈接與末尾的哈希和點。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.