AWS Amplify storage Error listing S3 bucket AWSS3Provider – list InvalidArgument TypeError: Cannot read properties of undefined (reading ‘byteLength’) [closed]

I have a problem when retrieving files from S3 Storage. There seems to be a permissions problem but we cannot find it.
We are using Amplify with S3 Storage and trying to Storage.list() the files inside a bucket but we get the error “AWSS3Provider – list InvalidArgument TypeError: Cannot read properties of undefined (reading ‘byteLength’)”.
We have 2 applications, each one with its own User Pool but with the same S3 Bucket. One of them has a php backend and there’s no problem accessing the bucket (I’m using presigned URLs). In the other (an Amplify app), on the contrary, we try to access bucket files with the following code:
const s3BucketObjects = await Storage.list('', { pageSize: 'ALL' });
but cannot retrieve the information. In this one we imported the storage (amplify import storage, and picked the corresponding bucket).

Some configurations:
We set S3FullAccess Role for amplify CLI user, Identity Pool and Cognito’s AuthRole and UnauthRole.
The bucket policy is:
{ "Version": "2012-10-17", "Id": "Policy16…", "Statement": [ { "Sid": "Stmt16…", "Effect": "Allow", "Principal": "", "Action": [ "s3:GetObject", "s3:DeleteObject", "s3:PutObject" ], "Resource": "arn:aws:s3:::my-storage/" } ] }
In amplify/backend/storage/myProject/parameters.json we have:
{ "resourceName": "myProject", "serviceType": "imported" }
Some things to take into account:
We’ve seen different examples that have more information in parameters.json file regarding users roles but when we run amplify pull, this file doesn’t get updated.
In the AWS documentation examples, when a storage is imported, it specifies the bucket access pattern (public, protected or private) but we don’t have that in our bucket, we have customed “directories” (see the attached image as an example).
Example customed folders

Intenté resolver el problema de acceso a archivos en S3 Storage utilizando Amplify. Esperaba que al ejecutar el código const s3BucketObjects = await Storage.list(”, { pageSize: ‘ALL’ });, pudiera listar los archivos en el bucket de S3. Sin embargo, en su lugar, recibí el siguiente error: “AWSS3Provider – list InvalidArgument TypeError: Cannot read properties of undefined (reading ‘byteLength’)”. He revisado la configuración de roles y permisos en Amplify, Cognito y el cubo de S3, pero aún no he podido resolver este problema de permisos.

Leave a Comment