Store image to key-value-store?

Hello - i try to save an png-image to a key-value-store from a https-link using the following code: kvs = await Actor.open_key_value_store(name='my-cool-key-value-store') picLink = "https://rapidtech1898.com/wp-content/uploads/2023/11/openai_dall_created-560x320.png" resp = requests.get(picLink, stream=True) img = Image.open(resp.raw) await kvs.set_value('explicit_image', img, content_type='image/png') But i get this error: TypeError: a bytes-like object is required, not 'PngImageFile' [apify] INFO Exiting Actor ({"exit_code": 91}) Error: "C:\DEV.venv\apify\Scripts\python.exe" exited with code 91 How can i store the image to a key-valuie-store?
Solution:
I think i found the solution - using the following code: picLink = "https://rapidtech1898.com/wp-content/uploads/2023/11/openai_dall_created-560x320.png" resp = requests.get(picLink, stream=True) await kvs.set_value('explicit_image', resp.content, content_type='image/png')...
Jump to solution
1 Reply
Solution
RapidTech1898
RapidTech18986d ago
I think i found the solution - using the following code: picLink = "https://rapidtech1898.com/wp-content/uploads/2023/11/openai_dall_created-560x320.png" resp = requests.get(picLink, stream=True) await kvs.set_value('explicit_image', resp.content, content_type='image/png')

Did you find this page helpful?