Hello, Waldemar!
In YouTrack comment and attachment are treated as related if attachment was created right after the comment (in 1 minute indeed). So you can just create comment and the attach file with same logged in user - this should work.
Does it works for you?