1

I'm writing a plugin which synchronizes the content from an external database with the Craft database.

For the images I receive URL's to the external image then store them in the temp storage and upload them to Craft assets, which works fine.

I now want to check additionally if the image in the temp already exists in crafts assets and if the images are identical ( checking for file size ).

Ideally comparing the external image and the image in the assets even before saving the external one to the temp.

The file size from the external source is identical to the tmp saved file but after uploading the file to Craft it somehow gets a little bit bigger so checking for the file size doesn't work.

Am I doing something wrong ? Should I check for something else than filesize?

This might be related to this question

1 Answer 1

1

It is related to the linked question since any images uploaded through Craft's AssetsService go through a "cleansing" process to remove any potentially embedded malicious scripts so the file size will inevitably be +/- the original by a small percentage.

What you can do is instead of uploading through the AssetsService, programmatically copy the file to the final destination on the file system in an Asset Source, then trigger Asset indexing like how the ToolsController does for the AssetIndexTool. That will bypass any cleansing operations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.