Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started


question avatar image asked commented

How do I insert a jpeg into a blob? Is there an imageAsBlob() conversion?

CREATE TABLE bios ( user_name varchar PRIMARY KEY, 
   bio blob

INSERT INTO bios (user_name, bio) VALUES ('fred', bigintAsBlob(3));

I want to send a stream of images to cassandra from kafka and would expect to find some mention of how to a) convert a small image file b) read a filename from hard disk.

Am I barking up the wrong tree?

10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered commented

Unfortunately, no. There are no image conversions for the reason that a database stores data -- it isn't an application that is capable of things such as processing images.

The only valid conversions are:

  • native CQL data type to blob
  • blob to native CQL data type

A blob type stores data in binary format. Do you really need to do convert the underlying JPEG binary data? I imagine your app should be able to handle reading the binary data to store into a blob and vice versa. Cheers!

4 comments Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Thanks Eric. Sometimes you have to ask the dumb question to find the right answer.

0 Likes 0 ·

It was actually a good question. I never looked at it that way until you asked so thank you because I learnt something new too. It's why I like answering questions. Cheers!

2 Likes 2 ·

My day is full of joy. Now that I know how to create a blob, I am wrangling with the com.datastax.examples:storing-and-retrieving-blobs example. Gitpod doesn't like me much

0 Likes 0 ·