boto3 cognito : set_ui_customization call not working.
See original GitHub issueI am trying to upload logo file for custom UI for Hosted Domain. Below is my source code.
def readImage():
with open("./utils/png-file-6-1.png", "rb") as image:
f = image.read()
b = bytearray(f)
return b
def set_ui_customization():
bytes_a = readImage()
client = boto3.client('cognito-idp', region_name=self.region_name)
response = client.set_ui_customization(
UserPoolId='abc',
ClientId='pqr',
#CSS='string',
ImageFile=bytes_a
)
print('done')
print(response)
Its giving error :
Traceback (most recent call last): File “/var/task/verify.py”, line 28, in lambda_handler cognito.set_ui_customization(‘abc’, ‘pqr’) File “/var/task/utils/cognitoUtils.py”, line 320, in set_ui_customization response = client.set_ui_customization( File “/var/runtime/botocore/client.py”, line 272, in _api_call return self._make_api_call(operation_name, kwargs) File “/var/runtime/botocore/client.py”, line 576, in _make_api_call raise error_class(parsed_response, operation_name) botocore.errorfactory.InvalidParameterException: An error occurred (InvalidParameterException) when calling the SetUICustomization operation: The uploaded image must be a valid .jpeg or .png file.
- The provided file is working from AWS console UI, but not from boto3 functions.
- Do you have any sample code for how to provide “ImageFile”. Documentation just says Uploaded image file which is not sufficient.
@swetashre : Could you please help on this.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
@vlakken ,
For cli please give image file argument like, --image-file fileb://./Logo.png Please refer : https://stackoverflow.com/questions/50692326/invalid-png-format-in-set-ui-customization-in-aws-cognito
@swetashre ,
Thanks for the reply, Problem was with my image file, I changed it and it started working.