Add type parameter to upload_media

Use the file extension if a type value isn't provided.