Generate the Pre-Signed URL of Querying Data Points
Last Updated:2020-07-20
The Pre-signed URL can be use to query data points on the front-end page. Usage: The front-end requests the server to generate a pre-signed URL and return it to the front-end, which uses the URL to initiate ajax requests to query data points.
Generate a Pre-Signed URL Based on Query Objects
timestamp = int(time.time())?? # specify the time stamp for the computed signature
expiration_in_seconds = 1800?? #specify the expire date for url
per_signed_url = tsdb_client.generate_pre_signed_url(query_list,??????????????
????????timestamp=timestamp, expiration_in_seconds=expiration_in_seconds)??? # generate the pre-signed URL
print per_signed_url
Return result:
http://databasename.tsdb.iot.bj.baidubce.com/v1/datapoint?authorization=bce-auth-v1%2Fa85ed2d7649141e08bf79fbbd88edc12%2F2018-07-23T10%3A06%3A46Z%2F1800%2F%2Fbe601040db0e5aa8f959248651b5ea7373c5d22fbece0d34eb21eb5cc8763f02&disablePresampling=False&query=%7B%22queries%22%3A%20%5B%5D%7D
Generate a Pre-Signed URL Based on SQL
You can refer to the following code:
sql = "select * from wind"
timestamp = int(time.time())
per_signed_url_sql = tsdb_client.generate_pre_signed_url_with_sql(sql,
timestamp=timestamp, expiration_in_seconds=1800)
print per_signed_url_sql
Return result:
http://databasename.tsdb.iot.bj.baidubce.com/v1/row?authorization=bce-auth-v1%2Fa85ed2d7649141e08bf79fbbd88edc12%2F2018-07-23T10%3A26%3A33Z%2F1800%2F%2F73c721bff21300c17d8ec4e1fab94b6cbf91672c33417276808c534c85163b1d&sql=select%20%2A%20from%20wind