Cloud Sharing
Cloud Sharing is a service that allows you to share files or folder with other users of Secrecy.
Get the client
import { getSecrecyClient } from '@secrecy/lib';
// Get the client
const client = getSecrecyClient('prod');
sharedNodes()
Get the list of nodes that are shared.
const response = await client.cloud.sharedNodes();
if (!response) {
throw new Error(`Error`);
}
switch (response.__typename) {
case 'ErrorAccessDenied':
throw new Error(`Access Denied`);
case 'SuccessResponse': {
const nodes = response.data;
// Do something with the shared nodes
}
}
nodesSharedWithMe()
Get the list of nodes that are shared with me.
const response = await client.cloud.nodesSharedWithMe();
if (!response) {
throw new Error(`Error`);
}
switch (response.__typename) {
case 'ErrorAccessDenied':
throw new Error(`Access Denied`);
case 'SuccessResponse': {
const nodes = response.data;
// Do something with the nodes shared with me
}
}
deleteNodeSharing()
Remove a node sharing.
const response = await client.cloud.deleteNodeSharing({
nodeId: 'NODE_ID',
userId: 'USER_ID',
});
if (!response) {
throw new Error(`Error`);
}
switch (response.__typename) {
case 'ErrorAccessDenied':
throw new Error(`Access Denied`);
case 'SuccessResponse': {
const boolean = response.data;
// Do something with the boolean
}
}
shareNode()
Share a node with someone.
import { Rights } from '@secrecy/lib';
const response = await client.cloud.shareNode({
nodeId: 'NODE_ID',
rights: Rights.read,
userId: 'USER_ID',
});
if (!response) {
throw new Error(`Error`);
}
switch (response.__typename) {
case 'ErrorAccessDenied':
throw new Error(`Access Denied`);
case 'ErrorNotFound':
throw new Error(`Not Found`);
case 'SuccessResponse': {
const boolean = response.data;
// Do something with the boolean
}
}
Parameters
Parameter | Description | Type | Default |
---|---|---|---|
nodeId | The node id of the node. | string | required |
rights | The rights of the node. Either read , write or admin . | Rights | required |
userId | The user id of the user. | string | required |