apify-sdk-python icon indicating copy to clipboard operation
apify-sdk-python copied to clipboard

AttributeError: 'KeyValueStore' object has no attribute 'get_public_url'

Open pawel-krzych opened this issue 1 year ago • 2 comments

In the SDK documentation we can find that:

Public URLs of records To get a publicly accessible URL of a key-value store record, you can use the KeyValueStore.get_public_url() method.

print(f'"my_record" record URL: {await store.get_public_url('my_record')}')

but there is an error:

AttributeError: 'KeyValueStore' object has no attribute 'get_public_url'

Sample code that generates an error:

page = await context.new_page()
await page.goto(url)

screenshot = await page.screenshot(full_page=True)

key_value_store = await Actor.open_key_value_store()
screenshot_key = f"screenshot_{request.id}.png"
await key_value_store.set_value(
    screenshot_key,
    screenshot,
    content_type="image/png",
)

screenshot_url = await key_value_store.get_public_url(
    screenshot_key
)

pawel-krzych avatar Oct 02 '24 17:10 pawel-krzych

I guess that as a temporary solution it can be hardcoded: https://api.apify.com/v2/key-value-stores/{key_value_store.id}/records/{record_key}?attachment=true

pawel-krzych avatar Oct 02 '24 17:10 pawel-krzych

Hello, there is an issue in crawlee-python tracking this - https://github.com/apify/crawlee-python/issues/514. We may want to update the docs before that is resolved.

janbuchar avatar Oct 03 '24 08:10 janbuchar