Try this in a .tcl file (without an .adp file):
ReturnHeaders $mime_type
db_write_blob write_content {
select content from cr_revisions where revision_id=:revision_id
}