[英]Displaying a PDF file stored in a Dataset on Palantir Foundry in Slate Application
I am trying to display PDF files in Slate on Palantir Foundry.我正在尝试在 Palantir Foundry 的 Slate 中显示 PDF 文件。 I managed to display PDF files that are stored in a folder on Foundry without a schema, but not PDFs that are in a Dataset.
我设法显示存储在 Foundry 文件夹中的 PDF 文件,但没有模式,但不是数据集中的 PDF。
Is there a way to display PDF files that are stored in a dataset or alternatively how can I store PDF files that I extracted from an email file using Code Repository into a folder on Foundry.有没有办法显示存储在数据集中的 PDF 文件,或者如何将使用代码存储库从电子邮件文件中提取的 PDF 文件存储到 Foundry 的文件夹中。
Edit: Since displaying PDF files stored in a dataset seems to be difficult.编辑:由于显示存储在数据集中的 PDF 文件似乎很困难。 Can someone help me with the API call to store PDFs in a folder?
有人可以帮助我通过 API 调用将 PDF 存储在文件夹中吗?
You can do it in two steps:您可以分两步完成:
image
widget in Slate where you specify the source as the address from #1.image
小部件,您将源指定为 #1 中的地址。 You can get 1 by looking at the address of any single file (dataset view -> details -> files).您可以通过查看任何单个文件的地址(数据集视图 -> 详细信息 -> 文件)来获得 1。 It will usually be in the shape of
(...)/foundry-data-proxy/api/web/dataproxy/datasets/<dataset_rid>/transactions/<transaction_rid>/filename
它通常是
(...)/foundry-data-proxy/api/web/dataproxy/datasets/<dataset_rid>/transactions/<transaction_rid>/filename
I found a solution for saving files in a Palantir Foundry folder:我找到了将文件保存在 Palantir Foundry 文件夹中的解决方案:
def upload_file(token: str, target_filename: str, parent_folder_rid: str, content_type: str, raw_data) -> None:
header = {'content-type': "application/json",
'authorization': f"Bearer {token}"}
target = urllib.parse.quote(tgt_filename, safe='')
response = requests.post(f"{blobster}salt?filename={target}&parent={parent_folder_rid}",
headers=header,
verify=True,
data=raw_data)
return response.json()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.