Robocorp Asset Storage

1.1.0 · active · verified Tue Apr 14

robocorp-storage is the Robocorp Asset Storage library, providing functions to manage (read, write, list) assets in the Robocorp Control Room or local development environment. It is part of the larger Robocorp ecosystem, typically updated alongside other Robocorp libraries, with a focus on stability for its core asset management API. The current version is 1.1.0.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set and retrieve a simple text asset. When run locally, assets are stored in a temporary directory. When executed within a Robocorp Control Room robot, assets are securely stored in the cloud. The optional cleanup code is commented out as it's typically for local development.

from robocorp.storage import get_asset, set_asset
import os

# Assets stored via robocorp-storage are persisted in Robocorp Control Room
# when run in a robot, or in a local temporary directory otherwise.

asset_name = "my-robot-state"
asset_value = "Current processing step: Data extraction complete."

print(f"Setting asset '{asset_name}'...")
# Assets are typically stored as bytes, hence the .encode()
set_asset(asset_name, asset_value.encode("utf-8"), "text/plain")
print(f"Asset '{asset_name}' stored.")

print(f"Retrieving asset '{asset_name}'...")
asset = get_asset(asset_name)

if asset:
    retrieved_value = asset.get_bytes().decode("utf-8")
    print(f"Successfully retrieved asset: '{retrieved_value}'")
    assert retrieved_value == asset_value
else:
    print(f"Asset '{asset_name}' not found.")

# Example of clearing assets (useful for local development cleanup)
# from robocorp.storage import clear_assets_from_disk
# if os.environ.get("RC_API_SECRET") is None: # Only clear if running locally, not in Control Room
#    clear_assets_from_disk()

view raw JSON →