Overview
The issue involved migrating user avatar images via REST APIs, with the challenge of locating image URLs. The solution required exporting metadata, downloading images, and updating profiles using REST API. The process was successfully completed, and the ticket was closed.
Resolution Steps
-
Export Legacy Avatar Metadata:
- Run a SQL query against your current database to extract
user_id,avatar_name,avatar_themeandavatar_collection.
- Run a SQL query against your current database to extract
-
Download High-Resolution Avatar Images:
- For each user, use the following API to download images:
GET https://your_instance.domain.com/t5/image/serverpage/avatar-name/{AVATAR_NAME}/avatar-theme/{THEME}/avatar-collection/{COLLECTION}/avatar-display-size/print/version/2 - Save each file locally as {USER_ID}.png or .jpg.
- For each user, use the following API to download images:
-
Upload Images to Aurora:
- Sign in as an admin and navigate to Designer → Theme → Avatars → Add custom avatars.
- Upload all images, ensuring they are square and at least 300 px.
- Publish the theme, maintaining the folder hierarchy.
-
Confirm Avatar Permissions:
- Ensure the role running the script has permissions for "Upload own avatar" and "Choose avatar from collections".
-
Attach Avatar to User Profiles:
- Aurora’s GraphQL API doesn’t expose user avatars yet, so use the classic v1 admin REST endpoint that updates the
url_iconprofile field:POST /users/id/{USER_ID}/profiles/name/url_icon/set?value=avatar:{THEME}/{COLLECTION}/{AVATAR_NAME} - Example cURL command:
curl -X POST -H "Li-Api-Session-Key: YOUR_ADMIN_SESSION_KEY" "https://your_instance.domain.com/users/id/117600/profiles/name/url_icon/set?value=avatar:candy/architecture/orthodox"
- Aurora’s GraphQL API doesn’t expose user avatars yet, so use the classic v1 admin REST endpoint that updates the
Best Practices:
- Use an admin-level session key for modifications.
- Overwrite files with the same name to avoid broken links if images need updating.
Additional API for High-Resolution Images:
- Use
/users/id/{USER_ID}/profiles/avatar/size/printor/users/id/{USER_ID}/profiles/avatar/size/unspecifiedfor fetching high-resolution images.
Frequently Asked Questions
- Q1: How can I download high-resolution avatar images?
- A1: Use the API endpoint
GET https://your_instance.domain.com/t5/image/serverpage/avatar-name/{AVATAR_NAME}/avatar-theme/{THEME}/avatar-collection/{COLLECTION}/avatar-display-size/print/version/2to download images.
Q2: What permissions are needed to update user avatars?- A2: Ensure the role has "Upload own avatar" and "Choose avatar from collections" permissions enabled.
Q3: What if I need to update an avatar image later?- A3: Overwrite the existing file with a new one of the same name to avoid broken links.
Ciprian Nastase
Comments