# How can I share an image with navigator.share?

**URL:** <https://forum.anaconda.com/t/how-can-i-share-an-image-with-navigator-share/35934>\
**Category:** PyScript\
**Created:** [September 12, 2022, 9:00am UTC](https://forum.anaconda.com/t/how-can-i-share-an-image-with-navigator-share/35934 "2022-09-12T09:00:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ilai.keinan](https://avatars.discourse-cdn.com/v4/letter/i/0075a9/32.png) [@ilai.keinan](https://forum.anaconda.com/u/ilai.keinan)\
**Post date:** [September 12, 2022, 9:00am UTC](https://forum.anaconda.com/t/how-can-i-share-an-image-with-navigator-share/35934/1 "2022-09-12T09:00:01Z")

</div>

I using it like this:

```auto
async def share_eq(e):
    base64url = document.getElementById('img').src
    blob = await (await fetch(base64url)).blob()
    file = File.new([blob], 'eq.png', {type: blob.type})
    navigator.share({
        "title": 'Generated EQ',
        "text": 'Can you solve this??',
        "files": [file],
    })

```

And it just prints out:

`Future exception was never retrieved\nfuture: <Future finished exception=JsException(TypeError: Failed to execute 'share' on 'Navigator': No known share data fields supplied. If using only new fields (other than title, text and url), you must feature-detect them first.)>`

And even tho I try also using url instead of files it returns the same error

---

<div class="post-metadata">

**Author:** ![JeffGlass](https://dub1.discourse-cdn.com/anaconda/user_avatar/forum.anaconda.com/jeffglass/32/1301_2.png) [@JeffGlass](https://forum.anaconda.com/u/JeffGlass)\
**Post date:** [September 12, 2022, 1:06pm UTC](https://forum.anaconda.com/t/how-can-i-share-an-image-with-navigator-share/35934/2 "2022-09-12T13:06:10Z")

</div>

Just sharing the solution we came up with over on the community discord for those who find this in the future:

`navigator.share()` [takes an Object as its only argument](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share), but the code above uses a Python Dict as the argument, which [gets converted](https://pyodide.org/en/stable/usage/type-conversions.html#python-to-javascript) to a JS Map.

Using `to_js(..., dict_converter=Object.fromEntries)` to convert the Python Dict to a JS Object works:

```python
data = { 
    "title": 'Generated EQ',
    "text": 'Can you solve this??',
    "files": [file] }
navigator.share(to_js(data, dict_converter=Object.fromEntries))

```

Or you could create a new Python object with `title`, `text` and `files` attributes. But I think the solution above is more Pythonic.
