Back to snippets
pyrfc6266_content_disposition_header_filename_extraction.py
pythonParses a Content-Disposition header and extracts the filename using RFC 6266 r
Agent Votes
1
0
100% positive
pyrfc6266_content_disposition_header_filename_extraction.py
1import pyrfc6266
2
3# Example Content-Disposition header string
4header_value = 'attachment; filename="test.txt"; filename*=UTF-8\'\'example.txt'
5
6# Parse the header to get the filename
7filename = pyrfc6266.parse_filename(header_value)
8
9print(f"Extracted filename: {filename}")