VichUploaderBundle: StorageInterface -> resolvePath() does not resolve directory path

I have the following lines:

    /**
     * @var StorageInterface $storage
     */
    private $storage;

  public function getFilePath(Entity $entity)
    {
         $file = $this->storage->resolvePath($entity, 'file');

        if ($file && file_exists($file)) {
            return $file;
        }

        return null;
    }

But the resolvePath() method only resolves file name instead of path name. I already tried switching $relative param to use use absolute and relavant but I had no luck. I am also using oneup_flysystem for file storage but it not seem to be the issue.

Is there any workaround to retrieve absolute file path while using vich uploader mappings?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 24 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Sorry, I don’t use Flysystem

See #858

Closing for missing feedback.

Fixed

@Dark-reaper this is an issue, it can’t be merged

Yeah there seems to be some confusion… the ‘Awaiting PR’ label was added… but a PR was submitted by myself a month before the label was added?

When is this going to be merged in to a stable release ?

You ask for my opinion (“what do you think”). I’m sorry, but since I don’t use Flysystem I can’t give you my opinion. This doesn’t mean that this bundle is not supporting Flysystem

@garak uri_prefix is not relevant to this issue (not related to filesystem path).

I am having the same problem. @rasanga did you overcome it?

Because the file is not properly located in the fs, the DownloadHandler is also failing, despite the file being uploaded properly. I require the uploads to be stored outside the pubic space (web/uploads) and served via controller.


oneup_flysystem:
    adapters:
        document_adapter:
            local:
                directory: "%kernel.root_dir%/../attachments"

    filesystems:
        document_fs:
            adapter: document_adapter
            mount: document_fs

vich_uploader:
    db_driver: orm
    storage:   flysystem
    mappings:
        document:
            uri_prefix:         /attachments
            upload_destination: document_fs
            delete_on_update:   true
            delete_on_remove:   true
            namer:              vich_uploader.namer_uniqid
            inject_on_load:     true