0

您好有一个后端模块扩展来上传文件。我使用 helhum fileupload 作为参考。文件上传成功。但是 table 的文件字段更新 sys_file_reference 的 uid 而不是文件的 no。为什么会发生?

<f:form.upload  property="file" />

我的参考是这个Where can I set the table name and no_files in my table and sys_file reference

4

2 回答 2

1

我假设的属性“文件”是 1:1 的关系,这就是为什么文件引用的 UID 是写入该字段的原因。

如果属性是 M:N 或 1:N 表,您将看到文件的数量,正如您所期望的那样 - Extbase 需要知道您想要一个包含 FileReference 对象的 ObjectStorage。

关于主题,如果您的 Repository 在您执行 findAll 时返回 NULL,这几乎总是因为存储页面限制。要克服它,请在返回之前覆盖 createQuery 并在查询上操作 QuerySettings,设置 respectStoragePageUids(false)。

于 2017-01-19T16:30:26.337 回答
0

我得到了我的问题的解决方案。我的模型是

/**
     * Sets the file
     *
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $file
     * @return void
     */
    public function setFile(\TYPO3\CMS\Extbase\Domain\Model\FileReference $file = NULL)
    {
        $this->file = $file;
    }

我从参数列表中删除了类型。现在它工作正常。我更新的代码如下

/**
 * Sets the file
 *
 * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $file
 * @return void
 */
public function setFile($file = NULL)
{
    $this->file = $file;
}
于 2017-02-01T05:49:59.100 回答