1

Is there a way of getting the Doctrine Uploadable extension to store a path relative to a directory in the database?

We use Capistrano to manage releases on our servers, so when a file is uploaded, the stored path looks like: /var/www/sitename/releases/20140625151300/web/uploads/$filename. While the files themselves are safe (uploads is a symlink), when the release is deleted the paths necome broken.

For example, the stored path could just be the filename or relative to %kernel.root_dir%.

4

1 回答 1

0

我遇到了同样的问题,我没有深入研究侦听器(我认为这是另一种可能性),而是在我的参数文件中设置了路径,然后在该stof_doctrine_extensions部分中引用了该参数。通过这种方式,它允许我拥有真实的路径,但允许它对于每个版本都不同。

app/config/parameters.yml

parameters:
    ....
    acme.upload.path: '/The/Absolute/Path/app/Resources/files/uploads'
    ....

app/config/config.yml

stof_doctrine_extensions:
    ....
    uploadable:
        default_file_path: %acme.upload.path%
    ....

如果您不使用stof捆绑包,那么我假设您只需将参数作为calls.

就像我说的那样,我很确定你可以进入听众并使用它,但我发现这是最简单的方法。

于 2014-06-25T14:48:01.417 回答