Skip to content

[FEATURE] Share images from API to clients #6

@mykolasolodukha

Description

@mykolasolodukha

Definitions:

  • electro - this framework.
  • API Server - any project/re pository that uses electro framework in the API mode (the only available mode right now).
  • Clients - any Discord/WhatsApp/Website/etc. clients that connect to the API and serve as a middleware between the API server and the platforms. Platforms = Discord, WhatsApp, etc.

What?

  • Whenever the API server wants to send an image to a Client (e.g. WhatsApp client), it sends an URL of that image as a field in the types.MessageToSend schema.

Why?

  • So that we can share images (and files) from the API Server to the clients.
  • Later we can have something similar be done in the other direction: whenever a User sends an image to the WhatsApp client, the Client uploads that image to a specific endpoint in the API, API returns the URL, and then the Client sends that URL as a part of the types.Message payload.

How?

  • Whenever an Image needs to be sent to the Client, it first needs to be uploaded to an S3/AzureBlobStorage instance using await universal_image_storage.upload_image(...) from ./electro/toolkit/images_storage/universal_image_storage.py.
  • To cover all the cases when an image/file needs to be shared, we can look at all the FilesMixin()._get_files_to_send() method from ./electro/flow_step.py. By looking at all the classes inherited from FilesMixin we can see how the method is being used.

Anything else?

  • The image URL should ideally be a presigned URL. If that's not possible to achieve for AzureBlobStorage, we can ignore it. It is acceptable to have images URLs be public as long as they're not easily guessable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions