How do I get a file from the Blobster API into a Foundry Transform?

505 Views Asked by At

I'm using the Blobster API to get files from within a (e.g.) Python transform in Foundry Code Repositories or Foundry Code Workbooks.

What's the best way to accomplish this?

2

There are 2 best solutions below

0
On

We had a use case to copy PDF files from a Compass folder to a dataset filesystem. I tried Andrew St P's answer but it did not work in our stack and returned a 404, assuming I understood it correctly to just append the token. This is what ended up working in our case, but I have no idea why, and this is completely undocumented. If anyone from Palantir is reading and has more insight feel free to comment!

from transforms.api import transform, Input, Output
import requests


 @transform(
     pdf=Output("OUT_PATH"),
 )
 def compute(pdf):

cookies = {
    'PALANTIR_TOKEN': 'AUTH_TOKEN',
}

response = requests.get(
    'https://your-foundry-instance/blobster/api/salt/ri.blobster.main.pdf.0466bc73-fe31-40a2-89d0-536ecff719a3',
    cookies=cookies,
)
0
On

Use /blobster/api/salt/*rid***/token**

If you use the endpoint sans /token with a classic {... 'Authorization': auth_token header} your request will return a redirect (307) response to the multipass login page. The response data will in fact be the html for the login page (probably not what you're after, nope, me neither).