5

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?

FloHab
  • 93
  • 6

2 Answers2

0

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

3yakuya
  • 2,622
  • 4
  • 25
  • 40
0

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()
FloHab
  • 93
  • 6