I have a problem with vich uploader, gaufrette and the VichUploaderSerializationBundle and I'm not really sure what is causing it.
I set vich to upload images to an S3 bucket using gaufrette which is working fine.
When I serialize my entity using the JMS Serializer the VichUploaderSerializationBundle will return the link to the S3 bucket.
All that is working fine except that on some seemingly random occasions it will append the S3 url to the database entry for the file name (it even will append it multiple times causeing things like UrlUrlUrlName...)
I have no clue what might be the cause for that because I don't update the entity at all.
vich_uploader:
db_driver: orm
storage: gaufrette
mappings:
product_image:
uri_prefix: 'https://s3-%aws_region%.amazonaws.com/%s3_bucket%/products' # you'll need this set to use the Vich URL generator
upload_destination: aws_s3_products
namer: vich_uploader.namer_uniqid
delete_on_remove: true
delete_on_update: true
knp_gaufrette:
stream_wrapper: ~
adapters:
products:
aws_s3:
service_id: 'aws.s3'
bucket_name: '%s3_bucket%'
options:
directory: 'products'
acl: 'public-read'
filesystems:
aws_s3_products:
adapter: products
/**
* @ORM\Column(type="string", nullable=true)
* @Fresh\VichSerializableField("imageFile", includeHost=false)
* @Expose
* @Groups({"default"})
*/
private $imageName;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Assert\File(
* maxSize="5M",
* mimeTypes={"image/png", "image/jpeg", "image/pjpeg"}
* )
* @Vich\UploadableField(mapping="product_image", fileNameProperty="imageName")
* @Expose
*
* @var File
*/
private $imageFile;
I really have no clue what's causing this strange behavior...
I already asked on the vich upload bundle but they said the root of the issue is more likely to be found here.