Add with_priority parameter to support both packet and file formats