Previous topic

API Helper functions

This Page

Images handling class

class mlapi.images.ImageStorage(storage_path, uuidgen=<function uuid4>, fopen=<built-in function open>)[source]

Contains methods for on-server images processing.

Attributes:
_storage_path: str

Path to a folder where the iages will be saved.

_uuidgen: uuid.uuid4, any function returning str

Function returning unique strings. `uuid.uuid4` by default

fopen: io.open, function opening files

Function that opens files. `io.open` by default

Methods

save(image_stream, image_content_type) Saves given image stream.
save(image_stream, image_content_type)[source]

Saves given image stream. Sets the extension basing on Content-Type.

Parameters:
image_stream: str

Stream of bytes, Base64 coded image, FileStorage

image_content_type: str

Type of image sent e.g “image/jpeg”, “application/json” etc.