I think you want to use io.BytesIO
see: https://docs.python.org/3/library/io.html#io.BytesIO
or: Creating and manipulating pdf files via PyPDF2 and FPDF
from io import BytesIO
file_byte_string = app_tables.quotes.get(quote_number='2-1001')['quote_pdf'].get_bytes()
with BytesIO(file_byte_string ) as f:
file_data = f.read()
file_type = imghdr.what(f.name)
file_name = str(f.name).split(chr(92))[-1]
I am not sure if the rest of your code will actually be able to get a name of a file from a byte string, if you stored your data as a media object it has information about the file like name, type etc.