> ## Documentation Index
> Fetch the complete documentation index at: https://docs.replit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage App Storage in Python

> Learn how to use the Python App Storage client library to manage files from your Replit App.

This guide demonstrates how to use the Python client library to upload, list, download, and delete files in your App Storage bucket.

## Create a Python Replit App

1. Select <img class="icon-svg" src="https://mintcdn.com/replit/rJldsgYVucXB_6kW/images/icons/create-app-icon.svg?fit=max&auto=format&n=rJldsgYVucXB_6kW&q=85&s=cc16ebed380bbd324dafaa2c93a91a66" alt="plus sign" width="16" height="16" data-path="images/icons/create-app-icon.svg" /> **Create App** from the home screen.
2. Navigate to the **Choose a Template** tab.
3. Type "Python" in the template search field and select it as shown below:
   <Frame>
     <img src="https://mintcdn.com/replit/0ixNWaRF232g0Gwn/images/tutorials/python-template.png?fit=max&auto=format&n=0ixNWaRF232g0Gwn&q=85&s=3d09d96320ab531aedf15df7894f1234" alt="Python template selection screen" width="2660" height="1110" data-path="images/tutorials/python-template.png" />
   </Frame>
4. Select <img class="icon-svg" src="https://mintcdn.com/replit/rJldsgYVucXB_6kW/images/icons/create-app-icon.svg?fit=max&auto=format&n=rJldsgYVucXB_6kW&q=85&s=cc16ebed380bbd324dafaa2c93a91a66" alt="plus sign" width="16" height="16" data-path="images/icons/create-app-icon.svg" /> **Create App**.

## Install the official client library

To install the client library, follow the one-click setup or package manager instructions below.

<Tabs>
  <Tab title="One-click setup">
    <Steps>
      <Step title="Access the App Storage tool">
        1. Navigate to the **App Storage** tab.
        2. Select the <img class="icon-svg" src="https://mintcdn.com/replit/rJldsgYVucXB_6kW/images/icons/angled-brackets.svg?fit=max&auto=format&n=rJldsgYVucXB_6kW&q=85&s=70ef5c07b2ba71181e96357f854e696a" alt="angled brackets icon" width="16" height="16" data-path="images/icons/angled-brackets.svg" /> **Commands** view in the **App Storage** tab.

        The installation screen should resemble the following screenshot:

        <Frame>
          <img src="https://mintcdn.com/replit/jSmYU1wBTvl8UMyc/images/databases/install-object-storage-deps.png?fit=max&auto=format&n=jSmYU1wBTvl8UMyc&q=85&s=c948e6bfa611ee9f80f6392e4931d212" alt="screenshot of App Storage package installation" width="1954" height="560" data-path="images/databases/install-object-storage-deps.png" />
        </Frame>
      </Step>

      <Step title="Install the dependencies">
        1. Select "Python" from the programming language dropdown on the top left.
        2. Select **Install replit-object-storage package**.
        3. When completed, the button text should read **Package installed**.
      </Step>
    </Steps>
  </Tab>

  <Tab title="upm">
    Use this option if your Replit App uses the Universal Package Manager (`upm`) to manage its dependencies.

    Open the **Shell** tool in the Project Editor and enter the following command:

    ```sh theme={null}
    upm --lang python add replit-object-storage
    ```
  </Tab>

  <Tab title="pip">
    Use this option if your Replit App uses `pip` to manage its dependencies.

    Open the **Shell** tool in the Project Editor and enter the following command:

    ```sh theme={null}
    pip install replit-object-storage
    ```
  </Tab>
</Tabs>

## Create a bucket

Before storing objects, you must create a bucket. Follow the steps below to create a new bucket:

1. Navigate to the **App Storage** tool
2. Select **Create new bucket**
3. Enter a name for the bucket in the **Name** field
4. Select **Create bucket**

## Add and run the example code

<Steps>
  <Step title="Locate main.py">
    Open the <img class="icon-svg" src="https://mintcdn.com/replit/rJldsgYVucXB_6kW/images/icons/files-icon.svg?fit=max&auto=format&n=rJldsgYVucXB_6kW&q=85&s=4b9ac8b70c07960d9f9a3f6eacee4ab6" alt="files icon" width="16" height="16" data-path="images/icons/files-icon.svg" /> **Files** tool from the left dock.

    Select `main.py` to open it in a file editor.
  </Step>

  <Step title="Add the client code">
    Copy and paste the following code into `main.py`:

    ```python theme={null}
    # Instantiate a Client
    from replit.object_storage import Client
    client = Client()

    # Upload a text file that contains the text "Hello, World!"
    client.upload_from_text("file.txt", "Hello World!")

    # List the objects in the bucket
    objects = client.list()
    print("Bucket contents:", objects)

    # Retrieve and print the contents of the uploaded file
    contents = client.download_as_text("file.txt")
    print("file.txt contents: ", contents)
    ```
  </Step>

  <Step title="Run the app">
    Select **Run** to execute the example code.

    Navigate to the **Console** tab to view the output, which should resemble the output below:

    ```
    Bucket contents: [Object(name='file.txt')]
    file.txt contents:  Hello World!
    ```

    Confirm that the `file.txt` object appears in your bucket in the **Objects** view of the
    **Object Storage** tool.

    <Tip>
      Reload the page to update the object list if `file.txt` fails to appear.
    </Tip>
  </Step>
</Steps>

## Delete the object

To remove the `file.txt` file from the bucket,

1. Replace the content of `main.py` with the following code:

   ```python theme={null}
   from replit.object_storage import Client
   client = Client()

   # Delete file.txt from the bucket
   client.delete("file.txt")
   print("Delete succeeded")
   ```
2. Select **Run** to execute the example code.
3. Navigate to the **Console** tab to view the output, which should resemble the output below:
   ```
   Delete succeeded
   ```
4. Verify that the `file.txt` object no longer appears in the bucket.

## Next steps

To learn more about Replit App Storage, see the following resources:

* [App Storage](/cloud-services/storage-and-databases/object-storage/): Learn more about the App Storage feature and how to use it in the Project Editor
* [App Storage Python SDK](/reference/object-storage-python-sdk): Learn about the `Client` class and its methods
