@textile/hub > Buckets > pushPathAccessRoles
Buckets.pushPathAccessRoles() method
Push new access roles per path in a Bucket
Signature:
pushPathAccessRoles(key: string, path: string, roles: Map<string, PathAccessRole>): Promise<void>;
Parameters
Parameter | Type | Description |
---|---|---|
key | string | Unique (IPNS compatible) identifier key for a bucket. |
path | string | A relative path within a bucket. |
roles | Map<string, PathAccessRole> | Each user public key and the roles they will receive. |
Returns:
Promise<void>
Example 1
import { Buckets, PublicKey } from '@textile/hub'
const grant = async (buckets: Buckets, key: string, peer: PublicKey) => {
const roles = new Map()
// NA = 0, Reader = 1, Writer = 2, Admin = 3
roles.set(peer.toString(), 2)
buckets.pushPathAccessRoles(key, '/', roles)
}
Example 2
Grant read access to everyone at a path (in an encrypted bucket)
import { Buckets } from '@textile/hub'
const grant = async (buckets: Buckets, key: string) => {
const roles = new Map()
// NA = 0, Reader = 1, Writer = 2, Admin = 3
roles.set('*', 1)
buckets.pushPathAccessRoles(key, '/folder/containing/shared/things', roles)
}