When inserting attachment into db, get the length from the temp file

This is the accurate length of the file since we have written all the bytes to disk.
Previously, this might have been inaccurate for attachments coming from streams etc.