added mimetype guessing, workable both local and url