stravalib.client.ActivityUploader#
- class stravalib.client.ActivityUploader(client: Client, response: dict[str, Any], raise_exc: bool = True)[source]#
The “future” object that holds information about an activity file upload and can wait for upload to finish, etc.
- __init__(client: Client, response: dict[str, Any], raise_exc: bool = True) None[source]#
Initializes the instance with the given client, response, and optional exception flag.
- Parameters:
client (stravalib.client.Client) – The
stravalib.client.Clientobject that is handling the upload.response (Dict[str,Any]) – The initial upload response.
raise_exc (bool) – Whether to raise an exception if the response indicates an error state. (default True)
Methods
poll()Update internal state from polling strava.com.
Raise an appropriate exception if the upload encountered an error.
update_from_response(response[, raise_exc])Updates internal state of object.
upload_photo(photo[, timeout])Uploads a photo to the activity.
wait([timeout, poll_interval])Wait for the upload to complete or to err out.
Attributes
Check if the activity upload completed successfully.
Check if the activity upload encountered an error.
Check if the activity upload is still being processed.
Photo metadata for the activity upload response, if any.
- property is_complete: bool#
Check if the activity upload completed successfully.
- Returns:
True if the upload completed and an activity_id was assigned.
- Return type:
- property is_error: bool#
Check if the activity upload encountered an error.
- Returns:
True if an error occurred during upload.
- Return type:
- property is_processing: bool#
Check if the activity upload is still being processed.
- Returns:
True if the upload is still processing (no activity_id yet and no error).
- Return type:
- property photo_metadata: Any#
Photo metadata for the activity upload response, if any. it contains a pre-signed uri for uploading the photo.
Notes
This is only available after the upload has completed. This metadata is only available for partner apps. If you have a regular / non partner related Strava app / account it will not work.
- poll() None[source]#
Update internal state from polling strava.com.
- Raises:
class – stravalib.exc.ActivityUploadFailed If poll returns an error.:
- raise_for_error() None[source]#
Raise an appropriate exception if the upload encountered an error.
- Raises:
stravalib.exc.ErrorProcessingActivity – If the upload status indicates a processing error.
stravalib.exc.CreatedActivityDeleted – If the created activity was deleted.
stravalib.exc.ActivityUploadFailed – For other upload failures.
- update_from_response(response: dict[str, Any], raise_exc: bool = True) None[source]#
Updates internal state of object.
- Parameters:
- Raises:
stravalib.exc.ActivityUploadFailed – If the response indicates an error and raise_exc is True. Whether to raise an exception if the response indicates an error state. (default True)
- upload_photo(photo: SupportsRead[bytes], timeout: float | None = None) None[source]#
Uploads a photo to the activity.
- Parameters:
Notes
In order to upload a photo, the activity must be uploaded and processed.
The ability to add photos to activity is currently limited to partner apps & devices such as Zwift, Peloton, Tempo Move, etc… Given that the ability isn’t in the public API, neither are the docs
- wait(timeout: float | None = None, poll_interval: float = 1.0) DetailedActivity[source]#
Wait for the upload to complete or to err out.
Will return the resulting Activity or raise an exception if the upload fails.
- Parameters:
- Returns:
class
- Return type:
stravalib.model.DetailedActivity
- Raises:
stravalib.exc.TimeoutExceeded – If a timeout was specified and activity is still processing after timeout has elapsed.
stravalib.exc.ActivityUploadFailed – If the poll returns an error. The uploaded Activity object (fetched from server)