Small note that it's unlikely that filename would be used as an attachment name but the default attachment name can be configured (see https://extensions.xwiki.org/xwiki/bin/view/Extension/Model%20Module#HFromStringandEntityReference).
For example:
model.reference.default.attachment = image.png
However, I still agree that I doubt many xwiki admins will have configured this...