0

I'm looking to save a file to cassandra

I'm using Scala with websudos" % "phantom-dsl_2.10" % "1.4.0" driver

I think I've got my model created with

sealed class CassandraRepoBlob extends CassandraTable[CassandraRepoBlob, CassandraBlob] {
  object id extends UUIDColumn(this) with PrimaryKey[UUID]

  object blobby extends BlobColumn(this)

and this seems to expect a case class of

case class CassandraBlob(
                        blobby: java.nio.ByteBuffer

I haven't been able to find many examples; so just want to check if I'm on the right track?

From here I guess I need to read my File to a ByteBuffer and I should be good to go?

Thanks

4

1 回答 1

0

“从这里我想我需要将我的文件读取到一个 ByteBuffer 并且我应该很好去吗?” 是的,当我使用 java 来写入具有 blob 类型的列作为文件内容的行时,我必须将文件内容转换为 ByteBuffer(实际上非​​常简单,ByteBuffer.wrap(Files.readAllBytes(file.toPath())))爪哇)。

于 2015-06-16T17:47:40.563 回答