API-of-Me
Search…
Attachments

Attaching a File to an Item

Every item in the meeco vault has the capability of having multiple files attached to it. The attachments are always attached to the item via a slot with the slot_type attachment. Assuming you have created an item already (such as the one you may have created in the getting-started page) and have the .item.config file still, lets create another item with that same config so as not to conflict with other steps later on in this guide.
1
meeco items:create -i .item-config.yaml -a .alice.yaml > .item2.yaml
Copied!
the next step is to create an attachment-config.yaml file with the following content.
1
kind: FileAttachment
2
metadata:
3
item_id: e8670e6c-8a95-43ff-a8d1-08805f612250 # (target item id from .item2.yaml)
4
spec:
5
label: 'Secret test webm video'
6
file: './test.webm'
Copied!
Then run the cli command
1
meeco items:attach-file -c attachment-config.yaml -a .alice.yaml > .attach-response.yaml
Copied!
You will get a response in the attach-response.yaml file that looks like the following
1
attachment:
2
id: fe9ef5ad-b29c-4b71-bb73-b14fd4b88dca
3
content_type: video/webm
4
filename: test.webm
5
...
6
slots:
7
- id: 67b2a8c2-4a4b-4a53-9b2f-5411cd63576b
8
attachment_id: fe9ef5ad-b29c-4b71-bb73-b14fd4b88dca
9
slot_type_name: attachment
10
item_id: e8670e6c-8a95-43ff-a8d1-08805f612250
11
label: My Secret File
12
encrypted_value: Aes256Gcm.z-T6OnEB6ssmkQK4RcvtYHjh2rE5PregqflhZoVXq6w=.QUAAAAAFaXYADAAAAAAhvEHoJqo845AsORoFYXQAEAAAAACahlEdh5rJcKfnl0DtTiaBAmFkAAUAAABub25lAAA=
13
...
14
item:
15
id: e8670e6c-8a95-43ff-a8d1-08805f612250
16
label: Item Label
17
slot_ids:
18
- 67b2a8c2-4a4b-4a53-9b2f-5411cd63576b
19
...
Copied!
Note: The slot's encrypted_value in this case is a new encryption key which has been encrypted with the user's own private data encryption key. The reason the file gets encrypted with a new data encryption key instead of directly with the user's existing private data encryption key has to do with sharing. By using this method when sharing, instead of having to re-encrypt the whole file with another data encryption key the slot's encrypted_value can simply be decrypted then re-encrypted with the data encryption key used for sharing.

Downloading the Attached File

To download an attached file the CLI needs to know the item's id and the slot's id, this is so the CLI can decrypt the data encryption key from the encrypted_value of the slot (as mentioned above). Both of these values can be found in the .attach-response.yaml file under slots[0].id and slots[0].item_id.
To download run the following
1
meeco items:get-attachment e8670e6c-8a95-43ff-a8d1-08805f612250 67b2a8c2-4a4b-4a53-9b2f-5411cd63576b -o ./output/ -a .alice.yaml
2
# meeco items:get-attachment <item id> <slot id> -o <file download path> -a <authorization>
Copied!

Sharing and receiving the attachment

Sharing an attachment simply works the same way you would share any other slot. First you will need to have a connection to another user, see the directions in the "Connections and Sharing" page to set up a connection first. Assuming you have a connection set up already and have the second user's info in a .bob.yaml file...
Run the command
1
meeco shares:create-config -i .item2.yaml -f .alice.yaml -c .connection.yaml > share-config2.yaml
2
# meeco shares:create-config -i <item id> -f .alice.yaml -c <connection id> > share-config.yaml
Copied!
To create the share config then to create the share itself
1
meeco shares:create -c share-config2.yaml > .create-shares-response.yaml
Copied!
You should see some output like the following in the .create-shares-response.yaml file.
1
shares:
2
- id: d9b68c36-110f-4171-8d9c-6bd580eff32d
3
owner_id: c1f2485d-fe8d-4de2-b45f-deee52931207
4
sender_id: c1f2485d-fe8d-4de2-b45f-deee52931207
5
recipient_id: ca14e3ae-d7c9-49fe-85ec-ac3306414803
6
public_key: "..."
7
encrypted_dek: Rsa4096.H-V2A_GlAbA3InFwKbdPoDVheM0p7kDIGg7tAtlnrF9-CFHtpo7pgE7MKBoszEp5jAkKwOlffZvaYt0ustjKb3yKDB-VKSKdZgu8yCkfJVNe8tgs5JpoZqg41krVrhVcUTLz6AsSfEXhnlFwKWLgbghqa7ad3u6LIGVVOTs_6-SBeuyJaYHDDBEN_TTiVqbIE7TU6LIUFSp38rpPOc0AM15FGZWhWcupYsy5gSO_jAOneBNi-sie392LX1LDPYbXi5fn-MSsWDektrR4bN0WlXA0iptTC-YqIrOFif9DFHL5qD5fis4Hfee95FCCPLBEtNoPNqU5u6YcE1a2XVlwPTMmeOVYDhHzl0HvT63QVc-zxhHqs3Tcg1mZtgDNb55qbUtNF8IGA1oOjG8LD69eIYOR3aO-cUs-iZcsZ-H0E7IqwX-bdCvZlLzUP1KI5sO3tIj32d9dCUCkvIJDf0TmPvB9UmF1rdoGDkT2dGvyGMA2sFQDhURq3I-NIOi4kp85h3l3JRN0BPcW1VzYCwX4Cn0HhG2brojv_Z8-j1QpCmOI9NO9XzJiMNi1ACMv-mJaEY4cBxvKtviY3eNaLsn8u-YrzH2InEOqrX7V9M2ynajf2YdJWxqCxUMXF_vWHxK04C6EQB2tdQ7SVNFchdjsuAjX-ue_RGmZ0hMNOXFCYjg=.QQUAAAAA
8
terms: null
9
expires_at: null
10
...
Copied!
to see the incoming shared item first make a request for items as bob run
1
meeco items:list -a .bob.yaml
Copied!
you will see something like the following as output
1
kind: Items
2
spec:
3
- id: fce07d6a-0c6d-4615-acef-46beee08bb5f
4
share_id: d9b68c36-110f-4171-8d9c-6bd580eff32d
5
own: false
6
name: item_label
7
label: Item Label
8
slot_ids:
9
- 9ddaa9f7-b928-4727-a0ee-6dfb487ca0c8
10
me: false
11
background_color: null
12
original_id: e8670e6c-8a95-43ff-a8d1-08805f612250
13
owner_id: c1f2485d-fe8d-4de2-b45f-deee52931207
14
...
Copied!
Notice how the share_id matches the share output from the previous command. We can then request the item itself.
1
meeco items:get fce07d6a-0c6d-4615-acef-46beee08bb5f -a .bob.yaml
2
# meeco items:get <item id> -a .bob.yaml
Copied!
Returning
1
kind: Item
2
spec:
3
id: fce07d6a-0c6d-4615-acef-46beee08bb5f
4
own: false
5
label: Item Label
6
slot_ids:
7
- 9ddaa9f7-b928-4727-a0ee-6dfb487ca0c8
8
original_id: e8670e6c-8a95-43ff-a8d1-08805f612250
9
owner_id: c1f2485d-fe8d-4de2-b45f-deee52931207
10
share_id: d9b68c36-110f-4171-8d9c-6bd580eff32d
11
...
12
slots:
13
- id: 9ddaa9f7-b928-4727-a0ee-6dfb487ca0c8
14
own: false
15
share_id: d9b68c36-110f-4171-8d9c-6bd580eff32d
16
attachment_id: 4ac61cad-7911-46e9-a9f8-659b1eb79fc6
17
item_id: fce07d6a-0c6d-4615-acef-46beee08bb5f
18
encrypted_value: Aes256Gcm.FYteKXIcTkjnC4OpqVcNFSzu5xwI3Eol0IubZUDpOhk=.QUAAAAAFaXYADAAAAACRE4YnWzELWDMfmE0FYXQAEAAAAACJtfJh93-EI7igsedpZ39aAmFkAAUAAABub25lAAA=
19
label: My Secret File
20
original_id: 67b2a8c2-4a4b-4a53-9b2f-5411cd63576b
21
value: "´ž\x10¹(MKnCȏ«BêSD\x01ˆ¾†]V*Ç\x16qøÀ¡^ó"
22
...
23
thumbnails: []
24
attachments:
25
- id: 4ac61cad-7911-46e9-a9f8-659b1eb79fc6
26
content_type: video/webm
27
filename: test.webm
28
...
Copied!
Now we have all the information we need to be able to download the attached file
1
meeco items:get-attachment fce07d6a-0c6d-4615-acef-46beee08bb5f 9ddaa9f7-b928-4727-a0ee-6dfb487ca0c8 -a .bob.yaml -o ./output/
2
# meeco items:get-attachment <item id> <slot id> -a <user auth> -o <file download output directory>
Copied!

Using the file-storage-browser or file-storage-node Packages

The above flow is a great start to understanding how everything works however for actual product implementation these npm packages are likely to be more useful so please head to the following links and check out the README.md files there.
Last modified 13d ago