You need to enable JavaScript to run this app.
Torch Object Storage

Torch Object Storage

Copy page
Download PDF
Best Practices
Tracking download behaviors with TOS Browser
Copy page
Download PDF
Tracking download behaviors with TOS Browser
TOS Browser provides a link tracking feature that allows you to track download behaviors after objects are shared. This topic describes how to track object download behaviors through the browser.​
How it works​
You can create trackable links with TOS Browser. When other users log in to TOS Browser via these links and download the corresponding objects, Torch Log Service (TLS) collects data on their download activity. Then, you can search for and analyze this data through TLS to understand the current status of the downloaded objects.​
Use cases​
Bioinformatics companies that perform gene sequencing accumulate extensive gene data. They must authorize downstream companies to develop testing products. Gene sequencing companies require real-time insights into whether downstream companies have successfully downloaded data during the authorization and delivery process. This information is essential for confirming that the delivery is complete. With this data, companies can promptly adjust object storage types or delete unnecessary data to minimize storage costs. With the link tracking feature in TOS Browser, gene sequencing companies can now monitor the status of data downloads in real time. This feature allows them to verify that downstream companies have fully downloaded the data, offering proactive insight into and visibility of the delivery process.​
Prerequisites​
You have activated TLS. For instructions, see Getting Started.​
Notes​
  • Using the link tracking feature incurs charges for log storage, index storage, write traffic, index traffic, service requests, etc. TLS bills these charges separately. For billing details, see TLS Billing items.​
  • TLS only collects data on object downloads via trackable links through TOS browser, not through any other browsers.​
Step 1: Create a TLS topic​
  1. Create a TLS project.​
  1. Log in to the TLS console.​
  1. In the top menu bar, select the region in which you want to create the TLS project.​
  1. In the left navigation pane, select Resource management > Project.​
  1. On the Project page, click Create project.​
  1. In the Create project dialog, configure Project name, Description, IAM Project, and Tag.​
tip​
For more information on the parameters for creating a TLS project, see Create project.​
  1. Once you have finished configuring, click Create.​
  1. Create a TLS topic.​
  1. On the Project page, click the project created in the previous step.​
  1. In the Topic section, click Create topic.​
  1. In the Create topic dialog, configure Topic name, Logs storage time configuration, and other parameters.​
tip​
For more information on the parameters for creating a TLS topic, see Create topic.​
  1. Once you have finished configuring, click Create.​
  1. Configure an index.​
  1. On the project details page, click the topic created in the previous step.​
  1. In the upper-right corner of the topic details page, click Index configuration.​
  1. In the Index configuration panel, enable the index feature. Then, select Key-value index, and create the index fields. The following two methods are supported:​
  • Manual configuration​
  • Click Add to manually configure Field name and Field type. For more information, see Field list.​
  • Automatic configuration​
  • First, share objects via TOS Browser to generate logs. Then, TLS can automatically build the index based on the raw logs. In the Index configuration panel, click Automatic configuration. Then, click Cover, and confirm by clicking OK in the box that appears.​
tip​
For more information, see Key-value index configuration.​
  1. Once you have finished configuring, click OK.​
  1. In the Prompt dialog, click OK.​
Step 2: Share an object​
You can create a trackable link using either TOS browser or the Python SDK.​
Sharing an object using TOS Browser​
  1. On the Buckets page, click the bucket you want to share.​
  1. On the Objects page, click ... > Share in the Actions column of the object you want to share.​
warning​
Only users who are logged in with AK can use the sharing feature. Users who log in with other methods cannot use this feature.​
  1. In the Share object dialog, set the URL validity period, enable link tracking, and configure the following parameters.​
  • ​
    Parameter​
    Description​
    TLS AK​
    The access key ID (AK) of the Volcano Engine account that uses TLS.​
    TLS SK​
    The secret access key (SK) of the Volcano Engine account that uses TLS. For instructions on how to view the AK and SK, see Viewing the Access Key ID and Secret Access Key.​
    warning​
    To prevent security issues caused by key leakage, strictly control access to your AK and SK.​
    TLS Host​
    The endpoint that you use to access TLS. For instructions on how to obtain the endpoint, see Endpoint.​
    tip​
    When setting the TLS Host, do not enter https://. Instead, enter tls-cn-beijing.ivolces.com, for example.​
    TLS Region​
    The region in which you created the TLS topic. TOS Browser automatically identifies the region based on the TLS Host that you provide.​
    TLS Topic ID​
    The ID of the TLS topic. On the topic details page, find the TLS topic ID in the Topic name/ID column.​
    ​
  1. Click Test sending logs.​
  1. After the page displays Logs sent successfully, click Create URL.​
  • In the Share object dialog, copy the URL. Share this link with other users, who can access the object through TOS Browser.​
Sharing an object using the Python SDK​
Make changes to the parameters in the example code below based on your specific situation, and then run the code to create a trackable link.​
​
import base64​
import os​
from Crypto.PublicKey import RSA​
from Crypto.Cipher import PKCS1_v1_5​
from urllib.parse import quote​
from tos import TosClientV2​
from tos.models2 import PolicySignatureCondition​
​
# TOS configuration: Specify your AK/SK through environment variables​
TOS_CONFIG = {​
"ak": os.environ["VOLCENGINE_ACCESS_KEY_ID"],​
"sk": os.environ["VOLCENGINE_ACCESS_KEY_SECRET"],​
"endpoint": "tos-cn-beijing.volces.com",​
"region": "cn-beijing"​
}​
​
# TLS configuration: Specify your AK/SK through environment variables​
LOG_CONFIG = {​
"ak": os.environ["VOLCENGINE_ACCESS_KEY_ID"],​
"sk": os.environ["VOLCENGINE_ACCESS_KEY_SECRET"],​
"topic_id": "c1a58ff6-9439-4316-bb26-0f97f4f4****",​
"endpoint": "tls-cn-beijing.volces.com",​
"region": "cn-beijing"​
}​
​
LOG_TOKEN = f"https://{LOG_CONFIG['endpoint']}?AK={LOG_CONFIG['ak']}&SK={LOG_CONFIG['sk']}&TopicId={LOG_CONFIG['topic_id']}&Region={LOG_CONFIG['region']}"​
​
# Preset fixed public key​
PUBLIC_KEY_BASE64 = "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUF0NVd0K29BYnlQMDJEWGZZSXZqaApzRThRY25BQnRkOHJSSVVIWHE3TmkxUmRiVjliRG4wQ0Zsb0syZVYvRzJwWjZsMHJ1NGZXYWhjWHFGMDREeTRoCkRrRWRJcHhzWlBLcVh0c01LaVNxSlZoTmpJZXVoVVZpN1dSeUJtWWk0cXU3V1k5RE5UU2dCSHYyNGtrNWR6NEYKYWVXdHcvRGJJVDdzOFJaSkc3NllxOHRRQ25TREkvd2ZLOEZwQlo3WW1WL1hUT0lFeVR4N2ZhcWdod3VzeVh1aApPQjA2aGRIUklyMTk0R0RGM1RaQ1U3NUE1cTVIcHM2UGtTQjJ3eW15ZEovWXE1SU1Dc3d6UEhEYTR4d3lxbzJuCnNUK1hHVmNYUzNmT1NhMFBIWWw4aC95RWhpR2hkNUJyVjhrWUlUS0dhNWdUenBMOUMwTWV2U3A5OGZyaWtDOGgKKzlBQjlHNXlFRjZ4YVdQR3JvRTJiWmtONzZyZUo5MXhOczZwWEdpeWI3Z1k4VndpU2tpVi8vczZ0ZmE2Y3B1bQpZQ0FsSksrakJta05hc21ZdW5aUkVET25kQ1VDYlVlZHJIUnFQcThQc0p2Vmw4T3JwdFo5U2dKRVJRaEtld2pJCnJNczA5djU4VC9aaUpGa0VLK2NaN3hEV2ZaeFBMOFdtQU1mdEhsdXlYRTdWSjREMXZBSnUzbWNHdkJLNE9DYVYKalJqT2ZTai9xU2xsUUVOc1ZRUTBSTWFJZHY5L0pyM29yZW5LTzdOUUVablhOV0tpVExaK1VqOVdETXdqdTN4YQpUdTcvODRFWFFmRDFVYUlXWlhDKzdvYlNjcmhkTDY5TDNUTmt0cFljNU4vY2JJRWtHWFZPVGhqQ0tnNzJJMkJECnlXUWV3KzJWYVVSa2ZOWmZJMTFHT3kwQ0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQ=="​
PUBLIC_KEY = base64.b64decode(PUBLIC_KEY_BASE64).decode('utf-8')​
​
# Website URL​
WEBSITE_URL = 'https://document-share.tos-cn-beijing.volces.com/v2/index.html'​
​
# Sharing configuration​
SHARECONFIG = {​
"bucket": "bucket-demo", ​
"conditions":​
{​
"key": "key",​
"value": "prefix/",​
"operator": "starts-with"​
},​
"expires": 3600​
}​
​
​
# Encryption method​
def encrypt_data(data):​
key = RSA.import_key(PUBLIC_KEY)​
cipher = PKCS1_v1_5.new(key)​
encrypted = cipher.encrypt(data.encode('utf-8'))​
res = base64.b64encode(encrypted).decode('utf-8')​
return res​
​
​
# Encoding method​
def encode(data):​
return base64.b64encode(data.encode('utf-8')).decode('utf-8')​
​
​
if __name__ == '__main__':​
# Create the client​
client = TosClientV2(​
ak=TOS_CONFIG["ak"],​
sk=TOS_CONFIG["sk"],​
region=TOS_CONFIG["region"],​
endpoint=TOS_CONFIG["endpoint"]​
)​
​
# Generate a pre-signed URL​
res = client.pre_signed_policy_url(bucket=SHARECONFIG["bucket"],​
conditions=[PolicySignatureCondition(key=SHARECONFIG["conditions"]["key"],​
value=SHARECONFIG["conditions"]["value"],​
operator=SHARECONFIG["conditions"][​
"operator"])],​
expires=SHARECONFIG["expires"])​
url = res.get_signed_url_for_list()​
​
# Make the URL trackable​
share_url = f"{WEBSITE_URL}?token={encode(url)}"​
if LOG_TOKEN:​
share_url += f"&logToken={quote(encrypt_data(LOG_TOKEN))}"​
​
print('share_url:', share_url)​
​
Configure the following parameters based on your situation:​
​
Parameter​
​
Description​
TOS_CONFIG​
ak​
The access key ID (AK) and secret access key (SK) for the Volcano Engine account that owns the bucket. For instructions on how to view the AK and SK, see Viewing the Access Key ID and Secret Access Key.​
By default, the example code obtains the AK and SK from the environment variables. Therefore, you must specify your AK and SK using environment variables. See Configuring long-term access credentials for instructions.​
​
sk​
​
​
endpoint​
For more information on TOS endpoints, see Regions and endpoints.​
​
region​
For more information on TOS regions, see Regions and endpoints.​
LOG_CONFIG​
ak​
The access key ID (AK) and secret access key (SK) for the Volcano Engine account that uses TLS. For instructions on how to view the AK and SK, see Viewing the Access Key ID and Secret Access Key.​
By default, the example code obtains the AK and SK from the environment variables. Therefore, you must specify your AK and SK using environment variables. See Configuring long-term access credentials for instructions.​
​
sk​
​
​
topic_id​
The ID of the TLS topic. On the topic details page, find the TLS topic ID in the Topic name/ID column.​
​
endpoint​
The endpoint that you use to access TLS. For instructions on how to obtain the endpoint, see Endpoint.​
​
region​
The region in which you created the TLS project and topic.​
SHARECONFIG​
bucket​
The name of the bucket from which you are sharing the object.​
​
value​
The name of the object you want to share.​
​
expires​
The time at which the link expires, measured in seconds.​
​
Step 3: Download the object​
Other users can log in to TOS browser using the trackable link to download the object you are sharing. For instructions, see Log in to TOS Browser using a trackable link.​
warning​
To log in to TOS Browser using a trackable link, your TOS Browser version must be V 1.10.3 or later. Earlier versions do not support this login method.​
Step 4: Query logs​
After the object has been downloaded via the trackable link, you can query the relevant logs using either the TLS console or the Python SDK.​
Field list​
The TLS log fields used for tracking object downloads include browserVersion and bucketName. These fields are explained below.​
​
Field name​
Field type​
Description​
browserVersion​
text​
The version of TOS Browser.​
bucketName​
text​
The name of the bucket from which you are sharing the object.​
category​
text​
Log category.​
failedReason​
text​
The reasons why TLS failed to collect logs on download activities.​
fileName​
text​
The name of the object you are sharing.​
fileSize​
long​
The size of the object, measured in bytes.​
logAK​
text​
The access key ID of the Volcano Engine account that uses TLS.​
originShareUrl​
text​
The trackable link.​
system​
text​
The operating system used by the client.​
taskStatus​
text​
Task status.​
updateTime​
text​
The time when the log was collected.​
downloadSize​
long​
The size of the downloaded object, measured in bytes.​
​
Querying logs using the TLS console​
  1. Log in to the TLS console.​
  1. In the top menu bar, select the region in which you created the TLS project.​
  1. In the left navigation pane, select Resource management > Project.​
  1. On the Project page, click the TLS project you created for the trackable link.​
  1. In the Topic section, click the TLS topic you created for the trackable link.​
  1. In the input box, enter the following statement: * | Select fileName,taskStatus,updateTime Where originShareUrl='<your URL>' order by updateTime. Then, click Search.​
  • Example:​
  • ​
    * | Select fileName,taskStatus,updateTime Where originShareUrl='https://document-share.tos-cn-beijing.volces.com/v2/index.html?token=****&logToken=****' order by updateTime​
    ​
  • The query result will then be displayed in the Raw log section.​
Querying logs using the Python SDK​
Make changes to the parameters in the example code below based on your specific situation, and then run the code to query logs.​
​
# coding=utf-8​
import os​
from volcengine.tls.TLSService import TLSService​
from volcengine.tls.tls_requests import *​
​
if __name__ == "__main__":​
# Initialize the client. For data security reasons, we recommend obtaining Volcano Engine AK/SK and other access credentials from environment variables, instead of hardcoding the keys. For more information, see https://www.volcengine.com/docs/6470/1166455.​
# When using temporary credentials of Security Token Service (STS), add a line for the VOLCENGINE_TOKEN parameter.​
endpoint = "tls-cn-beijing.volces.com"​
region = "cn-beijing"​
access_key_id = os.environ["VOLCENGINE_ACCESS_KEY_ID"]​
access_key_secret = os.environ["VOLCENGINE_ACCESS_KEY_SECRET"]​
topic_id = "c1a58ff6-9439-4316-bb26-0f97f4f4****"​
org_share_url = "https://document-share.tos-cn-beijing.volces.com/v2/index.html?token=****&logToken=****"​
query_sql = f"* | Select fileName,taskStatus,updateTime Where originShareUrl='{org_share_url}' order by updateTime"​
query_range_seconds = 3600​
end_time = int(time.time() * 1000)​
start_time = int((time.time() - query_range_seconds) * 1000)​
limit = 1000​
​
# Instantiate the TLS client​
tls_service = TLSService(endpoint, access_key_id, access_key_secret, region)​
​
# Query logs (SQL analysis)​
search_logs_request = SearchLogsRequest(topic_id, query=query_sql, limit=limit,​
start_time=start_time, end_time=end_time)​
search_logs_response = tls_service.search_logs_v2(search_logs_request)​
print(json.dumps(search_logs_response.response.get("AnalysisResult").get("Data"), indent=4, ensure_ascii=False))​
​
Configure the following parameters based on your situation:​
​
Parameter​
Description​
endpoint​
The endpoint that you use to access TLS. For instructions on how to obtain the endpoint, see Endpoint.​
region​
The region in which you created the TLS project and topic.​
access_key_id​
The access key ID (AK) and secret access key (SK) for the Volcano Engine account that uses TLS. For instructions on how to view the AK and SK, see Viewing the Access Key ID and Secret Access Key.​
By default, the example code obtains the AK and SK from the environment variables. Therefore, you must specify your AK and SK using environment variables. See Configuring long-term access credentials for instructions.​
access_key_secret​
​
topic_id​
The ID of the TLS topic. On the topic details page, find the TLS topic ID in the Topic name/ID column.​
org_share_url​
The trackable link.​
query_range_seconds​
The time range for the query, measured in seconds.​
limit​
The maximum number of log entries that can be retrieved.​
​
​
Last updated: 2025.11.18 14:49:33