Open spencer-kt opened 4 years ago
@wskish
One example when fp doesn't have a name
attribute is a file created from a buffer string.
from io import BytesIO
buf = 'some_image_as_a_string'
fp = BytesIO(buf)
What do you think about assigning a random filename when fp doesn't have a name
attribute ?
if not hasattr(fp, 'name'):
random_filename = "".join([sample(letters, 1)[0] for i in range(8)])
setattr(fp, 'name', random_filename)
If cc.create_media is called while the "fp" kwarg is set, the filename is just "file".