To share encrypted files with other users, FileKit must have a way to identify the recipients.

Identities fulfill this role, but they contain sensitive data, and thus must not be accessed by other users.

Their non-sensitive counterparts are public identities. They are used to represent recipients.

Public identities

Public identities can be retrieved using the Identity SDK:

publicIdentity, _ := identity.GetPublicIdentity(user.identity)

You can now share with the recipient's public identities.

Upload and share

The first way to share is to specify the recipients during the upload:

const aliceID = 'aliceID';
const alicePublicIdentity = await serverApi.getPublicIdentity(aliceID);

const file = document.getElementById('fileItem').files[0];
const fileId = await fileKit.upload(file, { shareWithUsers: [alicePublicIdentity] });

Once the file is uploaded, the file ID should be made available to the recipients. Otherwise, they will not be able to download the file.

Postpone share

It is possible to share already uploaded files to additional recipients:

const aliceID = 'aliceID';
const alicePublicIdentity = await serverApi.getPublicIdentity(aliceID);

const file = document.getElementById('fileItem').files[0];
const fileId = await fileKit.upload(file);

await fileKit.share([fileId], { shareWithUsers: [alicePublicIdentity] });

The next section will cover unregistered users.