DataStax Academy FAQ

DataStax Academy migrated to a new learning management system (LMS) in July 2020. We are also moving to a new Cassandra Certification process so there are changes to exam bookings, voucher system and issuing of certificates.

Check out the Academy FAQ pages for answers to your questions:


question

francisdomoney@aol.com avatar image
francisdomoney@aol.com asked ·

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));
 
SELECT * FROM bios;

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?

cassandra
10 |1000 characters needed characters left characters exceeded

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 ·

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 characters needed characters left characters exceeded

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 · ·
0 Likes 0 · ·
Erick Ramirez avatar image Erick Ramirez ♦♦ francisdomoney@aol.com ·

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 · ·