mypy-boto3-mediastore-data
Type annotations for the boto3 MediaStoreData service (version 1.42.3), generated with mypy-boto3-builder 8.12.0. This library provides type hints compatible with static analysis tools like mypy and IDEs such as VSCode and PyCharm, enhancing code completion and catching type-related errors early. It is actively maintained with releases frequently updated to match boto3 versions.
Warnings
- breaking Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0 and later. Users must use Python 3.9 or newer.
- breaking The `mypy-boto3` packages (including this one) migrated to PEP 561 compliant packaging in `mypy-boto3-builder` 8.12.0. This might change how some older or custom type-checking setups discover stubs.
- breaking TypeDef naming conventions changed in `mypy-boto3-builder` 8.9.0. Previously, some TypeDefs for packed method arguments had redundant `RequestRequestTypeDef` suffixes (e.g., `CreateDistributionRequestRequestTypeDef`). These are now shortened (e.g., `CreateDistributionRequestTypeDef`).
- gotcha For optimal code completion and type checking in IDEs like VSCode and PyCharm, it is recommended to use explicit type annotations for `boto3.client()` and `boto3.session.client()` calls.
- gotcha PyCharm users experiencing slow performance or high CPU usage due to Literal overloads (PyCharm issue PY-40997) might benefit from installing `boto3-stubs-lite` instead of the full `boto3-stubs` or `mypy-boto3-*` packages. The lite version is more RAM-friendly but requires more explicit type annotations.
Install
-
pip install mypy-boto3-mediastore-data -
pip install 'boto3-stubs[mediastore-data]'
Imports
- MediaStoreDataClient
from mypy_boto3_mediastore_data.client import MediaStoreDataClient
- PutObjectRequestTypeDef
from mypy_boto3_mediastore_data.type_defs import PutObjectRequestTypeDef
- PutObjectResponseTypeDef
from mypy_boto3_mediastore_data.type_defs import PutObjectResponseTypeDef
- StorageClassType
from mypy_boto3_mediastore_data.literals import StorageClassType
Quickstart
import boto3
from mypy_boto3_mediastore_data.client import MediaStoreDataClient
from mypy_boto3_mediastore_data.type_defs import PutObjectResponseTypeDef
def upload_to_mediastore_data(container_endpoint: str, object_path: str, data: bytes, content_type: str) -> PutObjectResponseTypeDef:
"""Uploads an object to AWS Elemental MediaStore Data plane."""
# Create a boto3 session. Credentials will be picked up from environment variables or ~/.aws/credentials
session = boto3.Session()
# Create a MediaStoreData client using the container endpoint
client: MediaStoreDataClient = session.client(
"mediastore-data",
endpoint_url=container_endpoint,
region_name=os.environ.get('AWS_REGION', 'us-east-1') # Or specify your region
)
print(f"Uploading object to {object_path} in container at {container_endpoint}...")
response: PutObjectResponseTypeDef = client.put_object(
Body=data,
Path=object_path,
ContentType=content_type,
# StorageClass='TEMPORAL' # Optional, default is TEMPORAL
# UploadAvailability='STANDARD' # Optional, default is STANDARD
)
print(f"Upload successful. ETag: {response.get('ETag')}, ContentSHA256: {response.get('ContentSHA256')}")
return response
# Example usage (replace with your actual endpoint and data)
if __name__ == "__main__":
import os
sample_endpoint = os.environ.get('MEDIASTORE_DATA_ENDPOINT', 'https://data.mediastore.us-east-1.amazonaws.com')
sample_path = "videos/my_video.mp4"
sample_data = b"This is some sample video content."
sample_content_type = "video/mp4"
if not sample_endpoint or sample_endpoint == 'https://data.mediastore.us-east-1.amazonaws.com':
print("WARNING: Please set the MEDIASTORE_DATA_ENDPOINT environment variable to your container's data endpoint.")
print("Skipping actual upload, showing example structure only.")
else:
try:
upload_to_mediastore_data(sample_endpoint, sample_path, sample_data, sample_content_type)
except Exception as e:
print(f"Error during upload: {e}")