laravel-paperclip icon indicating copy to clipboard operation
laravel-paperclip copied to clipboard

Re-uploading of image attachment with variants - variants have incorrect extension

Open nevedimko opened this issue 3 years ago • 0 comments

I added variants to my model's paperclip config and encountered a problem when re-uploading images. Original was uploaded as expected, but variants were uploaded with incorrect extension (from previous version).

Example: Firstly I uploaded image image.png and everything was good. Original and variants were uploaded and saved. Later I decided to replace image to image.jpg and original was uploaded correctly, but variants had incorrect extension png from previous version. I guess problem in methods variantFilename() of AttachmentData and Attachment classes. They return different results after interpolation. AttachmentData class returns path based on previous version of attachment, even in case of re-uploading.

Config:

        $this->hasAttachedFile('logo', [
            'storage' => 's3',
            'variants' => [
                Variant::make('thumb')->steps([
                    ResizeStep::make()->square(100)
                ]),
                Variant::make('small')->steps([
                    ResizeStep::make()->square(300)
                ]),
            ],
            'attributes' => [
                'variants' => true,
                'file_size' => false,
                'content_type' => false
            ]
        ]);

nevedimko avatar Aug 27 '21 09:08 nevedimko