Cogniac / cogniac-sdk-py

Python SDK for Cogniac Public API
Apache License 2.0
5 stars 6 forks source link

media uploads with filename "file" #72

Open spencer-kt opened 4 years ago

spencer-kt commented 4 years ago

If cc.create_media is called while the "fp" kwarg is set, the filename is just "file".

sergii-bond commented 3 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)