# Share your JupyterLite Examples

**URL:** <https://farmos.discourse.group/t/share-your-jupyterlite-examples/1134>\
**Category:** Development\
**Tags:** workflow\
**Created:** [February 12, 2022, 7:05pm UTC](https://farmos.discourse.group/t/share-your-jupyterlite-examples/1134 "2022-02-12T19:05:19Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![Symbioquine](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/symbioquine/32/284_2.png) [@Symbioquine](https://farmos.discourse.group/u/Symbioquine)\
**Post date:** [February 19, 2022, 4:22pm UTC](https://farmos.discourse.group/t/share-your-jupyterlite-examples/1134/11 "2022-02-19T16:22:48Z")

</div>

> [@walt](#):
>
> Works just fine for API access- nice! But when i upload a .CSV to that same directory in which the .ipynb resides, and try to do anything with it, it fails to find the file. Have tried every way i could think to get around this, and consulted @donblair about the problem… No joy

For now, you need this bit of magic that I’ve included in some of my examples above;

```Python
# From https://gist.github.com/bollwyvl/132aaff5cdb2c35ee1f75aed83e87eeb
async def get_contents(path):
    """use the IndexedDB API to acess JupyterLite's in-browser (for now) storage
    
    for documentation purposes, the full names of the JS API objects are used.
    
    see https://developer.mozilla.org/en-US/docs/Web/API/IDBRequest
    """
    import js, asyncio

    DB_NAME = "JupyterLite Storage"

    # we only ever expect one result, either an error _or_ success
    queue = asyncio.Queue(1)
    
    IDBOpenDBRequest = js.self.indexedDB.open(DB_NAME)
    IDBOpenDBRequest.onsuccess = IDBOpenDBRequest.onerror = queue.put_nowait
    
    await queue.get()
    
    if IDBOpenDBRequest.result is None:
        return None
        
    IDBTransaction = IDBOpenDBRequest.result.transaction("files", "readonly")
    IDBObjectStore = IDBTransaction.objectStore("files")
    IDBRequest = IDBObjectStore.get(path, "key")
    IDBRequest.onsuccess = IDBRequest.onerror = queue.put_nowait
    
    await queue.get()
    
    return IDBRequest.result.to_py() if IDBRequest.result else None

```

If you put that in the top cell of your notebook (and run it first), then you can access the contents of an “uploaded” (to the browser storage) file named “my\_file.csv” (as a `str` object) with;

```python
csv_str = (await get_contents("my_file.csv"))["content"]

```

Or if you _need_ a file object you can wrap that in [io.StringIO](https://docs.python.org/3/library/io.html#text-i-o). e.g.

```python
file_obj = io.StringIO((await get_contents("my_file.csv"))["content"])

```

---

_[View the full topic](https://farmos.discourse.group/t/share-your-jupyterlite-examples/1134)._
