Is your feature request related to a problem? Please describe.
If I have a camera that can capture in multiple formats then to follow the current instructions in the docs I would need to create a class for each format just to set the media_type string. Then a function either for each type of image with a specific return, or a large switch statement to decide what class to create.
I can create a blob directly with from_bytes, from_file, from_temporary_directory. Then once it is created change the media type property.
Describe the solution you'd like
Add an optional argument to set the "media_type" to the from_* class methods so I can go:
MEDIA_TYPES = {
".jpg": "image/jpeg",
".jpeg": "image/jpeg",
".png": "image/png",
".tiff": "image/tiff",
}
...
@lt.action
def image_as_blob(self):
filepath = self.capture_to_disk()
ext = os.path.splitext(filepath)[1]
media_type = MEDIA_TYPES[ext]
return lt.blob.Blob.from_file(filepath, media_type=media_type)
Additional context
Add any other context or screenshots about the feature request here.
Is your feature request related to a problem? Please describe.
If I have a camera that can capture in multiple formats then to follow the current instructions in the docs I would need to create a class for each format just to set the
media_typestring. Then a function either for each type of image with a specific return, or a large switch statement to decide what class to create.I can create a blob directly with
from_bytes,from_file,from_temporary_directory. Then once it is created change the media type property.Describe the solution you'd like
Add an optional argument to set the "media_type" to the
from_*class methods so I can go:Additional context
Add any other context or screenshots about the feature request here.