7

I came across a scenario i.e, Each and every node is to represent with an image . so i have to store image into neo4j. please healp me out with your views on it.

sparkyspider
  • 13,195
  • 10
  • 89
  • 133
Pavan Kumar Varma
  • 1,413
  • 1
  • 14
  • 22

2 Answers2

11

You have several options:

  1. As @Christophe Willemsen suggested you, save the image on disk or on a web site and reference it using a URL.
  2. Save it in byte[] array as a property.
  3. Save the image in base64 using a Data URI (as String).

Of course option 2 and 3 are not recommendable if the images are very large. Though you could save a thumbnail in the database and the full image on file system.

You should save some metadata too in properties, like type, size, location etc.. to improve searches in the database.

Community
  • 1
  • 1
onof
  • 17,167
  • 7
  • 49
  • 85
4

According to the Neo4j community:

  1. Don't add large blobs of data, e.g. base64, to the graph as property values. This is one of the few anti-use-cases for graph databases.
  2. Store the binary information somewhere, e.g. AWS S3, and have a node representing that photo or video. That node contains the S3 URL as reference and potentially some meta-data as well (width, height, quality, codec).
  3. Use relationships to amend information like tagging, comments, ownership and permissions.

Kudos to Stefan Armbruster (Neo4j Staff) for the info.