简体   繁体   中英

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. 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.

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.

Edit: Since displaying PDF files stored in a dataset seems to be difficult. Can someone help me with the API call to store PDFs in a folder?

You can do it in two steps:

  1. Obtain the precise address of the PDF you are trying to display.
  2. Use image widget in Slate where you specify the source as the address from #1.

You can get 1 by looking at the address of any single file (dataset view -> details -> files). It will usually be in the shape of (...)/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:

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM