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:
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:
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
POST v2/share/shareinfo
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.
DELETE v2/share/shareinfo
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.
/v2/share/shareinfo/shared (Shared to me)
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