This comment is not specific to this patch, but I'm wondering if common constants like 'image/jpeg', 'image/png' would be better defined as variables in a shared script as opposed to being duplicated as static strings in many different scripts.