Robocorp Asset Storage
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
- gotcha Asset persistence is context-dependent. When `robocorp-storage` is used outside of a Robocorp Control Room robot run (e.g., local development), assets are stored in a temporary directory and are not automatically synced to the cloud or persisted across process restarts unless explicitly configured.
- gotcha This library is designed for managing 'assets' (relatively small pieces of data or configuration files). For handling large datasets or multiple related files that form an input/output of a task, consider using `robocorp-workitems`.
- deprecated Older projects might have custom asset management solutions or rely on `rpaframework`'s `Vault` for some functionalities. `robocorp-storage` provides the official and recommended way to interact with Robocorp's Asset Storage.
Install
-
pip install robocorp-storage
Imports
- get_asset
from robocorp.storage import get_asset
- set_asset
from robocorp.storage import set_asset
- find_assets
from robocorp.storage import find_assets
- Asset
from robocorp.storage import Asset
Quickstart
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()