Skip to content

Instantly share code, notes, and snippets.

@marvinhoxha
Created September 8, 2022 13:12
Show Gist options
  • Save marvinhoxha/0c49f801a2faaed1ba97a522713d98b6 to your computer and use it in GitHub Desktop.
Save marvinhoxha/0c49f801a2faaed1ba97a522713d98b6 to your computer and use it in GitHub Desktop.
from kafka import KafkaProducer
import base64
def image_producer():
producer = KafkaProducer(bootstrap_servers='localhost:9092')
with open("./dogImages/test/002.Afghan_hound/Afghan_hound_00116.jpg", "rb") as imageFile:
str1 = base64.b64encode(imageFile.read())
producer.send('dogtopic', str1)
if __name__ == "__main__":
image_producer()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment