【发布时间】:2022-10-02 13:39:18
【问题描述】:
我想以编程方式创建 url 来下载文件。
为此,我需要workspaceUrl 和clusterOwnerUserId。
如何在 Databricks 笔记本中检索这些内容?
# how to get the `workspaceUrl` and `clusterOwnerUserId`?
tmp_file = \'/tmp/output_abcd.xlsx\'
filestore_file = \'/FileStore/output_abcd.xlsx\'
# code to create file omitted for brevity ...
dbutils.fs.cp(f\'file:{tmp_file}\', filestore_file)
downloadUrl = f\'https://{workspaceUrl}/files/output_abcd.xlsx?o={clusterOwnerUserId}\'
displayHTML(f\"<a href=\'{downloadUrl}\'>download</a>\")
标签: databricks