Sharing

The following documentation provides information on how to use the file-sharing feature within our SDK. To share files, an authTicket is required. You can obtain the authTicket by using the sdk.share

Public File Sharing

To share files publicly, you must provide the allocation ID and remote path to retrieve the authTicket.

AuthTicket format

The authTicket is encoded in Base64 format. To access the information contained within the authTicket, you can decode it to retrieve the following details:

ā— actual_file_hash: The actual hash of the shared file.

ā— file_name: The name of the shared file.

ā— reference_type: Indicates whether it is a file or a folder.

ā— expiration: The duration for which the authTicket remains valid.

ā— timestamp: The timestamp when the authTicket was created.

ā— encrypted: Indicates whether the authTicket is encrypted. If set to true, the sharing is private.

ā— signature: The signature of the authTicket.

File Sharing

To download a shared file; you can utilize the sdk.download function or consult the CLI documentation for detailed instructions. The authTicket and lookup_hash must be provided as parameters when downloading the file.

Folder Sharing

To list the files within a shared folder, the following information is required:

ā— Auth Ticket

ā— Lookup Hash

ā— Wallet ID of the owner

ā— Allocation ID of the owner

The lookup_hash can be obtained from the authTicket using the file_path_hash attribute. Similarly, the wallet_id and allocation_id can be extracted from the authTicket.

To list the files within the shared folder, you must retrieve the allocation (blobbers) details using the sdk.getAllocation function or the allocation details API. After that, you can select a random blobber from the allocation details. Each blobber has a URL, which needs to be combined with the endpoint "/v1/file/list/" to obtain the list of files.

Example code:

const blobber = getRandomArrayElement(allocationInfo.blobbers);
const params = `?path_hash=${lookup_hash}`;
const url = blobber.url + '/v1/file/list/' + allocationId + params; 

Note: When making the request, make sure to include the wallet ID of the owner in the headers using `X-App-Client-ID`.

A complete URL for listing the files may look like this:

https://demo3.zus.network/blobber01/v1/file/list/7aa73fdd041d1982a183bab4f23e75f53a09df
8bdb689375ace9b45b130607cd?path_hash=22f2d545e2cc579c793b8e153c26226b6b5373bf23f5a661ba
e06a9897b2352c

Private Sharing

To share files privately, you need to provide the allocation ID, remotePath, wallet ID of the receiver, and the encryption public key of the receiver to retrieve the authTicket.

You can use the corresponding API to obtain additional details, such as the wallet ID and encryption key of the receiver.

0box Share APIs Documentation

Public Share

We must pass the following data in the body as formdata; check the swagger for more reference.

Private Share

We must pass the following data in the body as formdata; check the swagger for more reference.

We can delete the share info by authTicket or lookup_hash.

GET

Check these endpoints on Swagger.

/v2/share/shareinfo/received (also add lookup_hash query param)

To get the list of users with access to the current file/folder.

This is the data Iā€™m showing here.

To get the list of private and public shared files.

/v2/share/shareinfo/shared/public

To get the list of only publicly shared files.

/v2/share/shareinfo/shared/private

The endpoint is not ready to get the list of only private shared files.

Last updated