KnpLabs / KnpGaufretteBundle

Easily use Gaufrette in your Symfony projects.
http://knplabs.com
MIT License
717 stars 157 forks source link

Gaufrette issue after editing object #98

Open rpostolov opened 10 years ago

rpostolov commented 10 years ago

Hi,

I'm on Symfony 2.3, i use knp_gaufrette bundle with vich_uploader bundle with admingenerator bundle. When i create a new object and i upload an image all works perfectly, my image is uploaded, my data base is updated with the name of image but when i want to edit (not update) this object i have this issue insteade of the form :

The specified path (gaufrette://drapeau_image_fs\53d8d34ee6d0e.jpg) is invalid.

Someone for help i search everywhere nad i found no solutions...

Here is my config :

PaysAdmin-generator.yml ... drapeauFile: label: Flag formType: afe_single_upload dbType: string addFormOptions: nameable: drapeau data_class: Symfony\Component\HttpFoundation\File\File previewImages: true previewAsCanvas: true previewFilter: drapeau200w200h ...

app/config.yml

knp_gaufrette: stream_wrapper: ~ adapters: drapeau_adapter: local: directory: %kernel.root_dir%/../web/images/drapeau

filesystems:       
    drapeau_image_fs:
        adapter:    drapeau_adapter

vich_uploader: db_driver: orm gaufrette: true twig: true storage: vich_uploader.storage.gaufrette

mappings:  
    drapeau_image:
        uri_prefix: /images/drapeau
        upload_destination: drapeau_image_fs
        namer: vich_uploader.namer_uniqid
        delete_on_remove: true # determines whether to delete file upon removal of entity
        delete_on_update: true #
        inject_on_load: true # determines whether to inject a File instance upon load
python33 commented 10 years ago

Hi, I working on windows now and have the same issue. Because of path separators "\" after using "parse_url" array parameter $parts['host'] takes both host an path parts. As a result $key variable becomes empty and you getting this error.

f.e.:

$path = "gaufrette://ckeditor_fs\545b52d0f2300_Hydrangeas.jpg";
$parts = parse_url($path);

# On windows $parts variable takes following result.
# array(5) {
#     ["scheme"] => string(9) "gaufrette"
#     ["host"] => string(40) "ckeditor_fs\545b52d0f2300_Hydrangeas.jpg"
#     ["path"] => NULL
#     ["query"] => NULL
#     ["fragment"] => NULL
# }

image

python33 commented 10 years ago

I think this issue should be referenced to Gaufrette library.