Miscellaneous

Generate a new key

Using elv:

Specify a directory to store the new key and a passphrase. This creates a new key and stores it, encrypted, in a keystore file. The keystore file can be decrypted using the passphrase used when creating it.

elv eth keyfile new  ~/.eluvio/keys/ <passphrase>

Retrieve the private key:

elv eth keyfile decrypt ~/.eluvio/keys/UTC--... <password>

Prepare the configuration file

Usually, qfab_cli commands check users’ permissions when operating fabric contents. One way is using configuration files. Depending on which network is hosting the content, users can find the corresponding network parameters (Space main, Config URL, Core, etc.) at Network Info.

Examples

Config files for Network 955210 (demo v3):

{
  "space_id": "ispc3ANoVSzNA3P6t7abLR69ho5YPPZU", //Space main
  "api": { "url": "https://host-76-74-91-17.contentfabric.io" },
  "fs": "os",
  "ethereum": {
    "url": "https://host-76-74-28-234.contentfabric.io/eth/",
    "private_key": "0x..."
  },
  "log": {
    "level": "warn",
    "formatter": "console",
    "named": {
      "/cli": {
        "level": "warn",
        "formatter": "console"
      },
      "/cli-result": {
        "level": "normal",
        "formatter": ""
      }
    }
  },
  "silence_error": false
}

where user can get space_id, api: url and ethereum:url by curl demo v3 Config URL, i.e.,

curl https://demov3.net955210.contentfabric.io/config | jq .

Export and import fabric contents

Once ingested, fabric contents can be exported and imported between the same or different users. The qfab_cli has two commands to achieve the goal qfab_cli content export and qfab_cli content import. Command manual can be found with qfab_cli content export -h and qfab_cli content import -h.

For encrypted contents, when exporting, everything is downloaded ‘as is’ (no decryption) even if a user (user A) provides the private owner key to be allowed to do the export.

A second user (user B) intends to import the content from a previous export. Usually, user B owns a different private key, probably from a different tenancy. At this point user B need to provide the previous owner user A’s key via flag --owner-key such that the content will be re-encrypted for user B’s private key.

Examples

Export encrypted contents to current working directory with content id and configuration file

See section Prepare the configuration file for creating configuration files

content id: iq__2NutX9Zw2yVP4XoU4YLCqLexCLi6
configuration file: userA_config.json

qfab_cli content export hq__KuAiAPcCGV188fU9HqmHA9iutaURybGJm534PecMHtF4PjYFQz9HiiM4gnWt7UrbYH4MYqn8KC --config userA_config.json

where user gets content hash by running

qfab_cli content versions list iq__2NutX9Zw2yVP4XoU4YLCqLexCLi6 --latest --config userA_config.json

Import the previous exporting encrypted content to a given content library

library id: ilibSxbDyChw94SWnKkAvrLrftJ3Yai
userA_private_key: the private key used to export the content
userB_config.json: configuration file providing network parameters where the library is hosted and user B’s private key

qfab_cli content import ilibSxbDyChw94SWnKkAvrLrftJ3Yai hq__KuAiAPcCGV188fU9HqmHA9iutaURybGJm534PecMHtF4PjYFQz9HiiM4gnWt7UrbYH4MYqn8KC --owner-key $(userA_private_key)  --config userB_config.json

File examples with elv CLI tool

Create a new object in a specified library and upload several files:

 elv files upload ./agent327_poster.png ./agent327_background.jpg --library ilib4RecAk7XXuuLJ7NZZAuGHCa3V31U --content '{"public":{"name":"Title - Agent 327"}}' --finalize

Upload a few more files into the same object:

 elv files upload ./agent327_thumbnail.png ./agent327_hero.jpg --library ilib4RecAk7XXuuLJ7NZZAuGHCa3V31U --qid iq__4JLRpVcRxE6v2rTMJ3b8yXGECCk9 --finalize

Download a file:

elv files download agent327_poster.png agent327_background.jpg --library ilib4RecAk7XXuuLJ7NZZAuGHCa3V31U --qid iq__4JLRpVcRxE6v2rTMJ3b8yXGECCk9

Files Download with API

/rep/files_download

The files download ‘rep’ creates a just-in-time zip file containing one or more files, as specified in the API request.

To initiate a files download request, use the Content Fabric /rep/files_download API for a given content object.

Example request:

POST /q/hq__DvHZN52C6bj8KY1xj3Cw4KqbVjXQJiNimsa6LcQUfyt8YcVPpx9LaYyma7USQnLR7KFV4WtY3G/rep/files/download

Request body:

{
    "files_list": [
        {
            "source":
            {
                "/":"/qfab/hq__DvHZN52C6bj8KY1xj3Cw4KqbVjXQJiNimsa6LcQUfyt8YcVPpx9LaYyma7USQnLR7KFV4WtY3G/meta/assets/main_poster.tiff"
            },
            "target":"Downloads/Assets/Posters/main_poster.tiff"
        }
    ]
}

Block Info

Get block info and time for a given content hash

~/go/bin/elvmastercli get-commit hq__72WornukxobH7aAPFBBQSzeSuffYjzTzxiLDQaqPpuxwn9kPV4ZK5WFyxr9tBwcPWXnAFgLvyf --ethurl https://host-38-142-50-110.contentfabric.io/eth/

INFO [05-25|19:09:01.147] block-info                               block-number=1557990
INFO [05-25|19:09:01.147] block-info                               tx-hash=0x88e70f8738f75d355886a2f57083ee8f9e6a26001643a1523efdc146f0a5aba0
INFO [05-25|19:09:01.147] block-info                               block-timestamp=2021-05-25T18:37:13-0700
INFO [05-25|19:09:01.147] block-info                               from=0xFfd68dDC29c65d52030767b5842404F7051839a7
INFO [05-25|19:09:01.147] event-details                            object-hash=hq__72WornukxobH7aAPFBBQSzeSuffYjzTzxiLDQaqPpuxwn9kPV4ZK5WFyxr9tBwcPWXnAFgLvyf
INFO [05-25|19:09:01.147] event-details                            parent-address=0x7C48f99eE50556A078bb7D891E6Db43b16f187d4
INFO [05-25|19:09:01.147] event-details                            space-address=0x9b29360EFB1169c801BBcBe8E50D0664DcbC78d3