minio / minio-dotnet

MinIO Client SDK for .NET
https://docs.min.io/docs/dotnet-client-quickstart-guide.html
Apache License 2.0
575 stars 230 forks source link

ListObjectsEnumAsync gives an System.Xml.XmlException: Root element is missing. #1184

Open wouterDevelop opened 1 month ago

wouterDevelop commented 1 month ago

I tried to implement the new ListObjectsEnumAsync function. But when I execute it, the code crashed and gives the following error:

    An unhandled exception has occurred while executing the request.
      System.Xml.XmlException: Root element is missing.
         at System.Xml.XmlTextReaderImpl.Throw(Exception e)
         at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res)
         at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
         at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
         at System.Xml.Linq.XDocument.Load(Stream stream, LoadOptions options)
         at Minio.MinioClient.ListObjectsEnumAsync(ListObjectsArgs args, CancellationToken cancellationToken)+MoveNext()
         at Minio.MinioClient.ListObjectsEnumAsync(ListObjectsArgs args, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()

when I have logging enabled, I get I think a getting a valid xml from the minio server

<?xml version="1.0" encoding="UTF-8"?>
<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>mediastorage</Name><Prefix></Prefix><KeyCount>3</KeyCount><MaxKeys>1000</MaxKeys><IsTruncated>false</IsTruncated><Contents><Key>7c9c9a49-8818-4d94-a2bc-d59e4caf6fea</Key><LastModified>2024-09-29T12:36:51.211Z</LastModified><ETag>&#34;449f26d4372db066e6ea857935e74c10&#34;</ETag><Size>95476</Size><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>936d03a9-971a-495b-a980-87c72fd69037_IMG_0343.jpg</Key><LastModified>2024-09-29T13:11:17.382Z</LastModified><ETag>&#34;449f26d4372db066e6ea857935e74c10&#34;</ETag><Size>95476</Size><StorageClass>STANDARD</StorageClass></Contents><Contents><Key>a1b9b74b-3628-430a-890e-2546d225c714</Key><LastModified>2024-09-29T13:00:46.271Z</LastModified><ETag>&#34;449f26d4372db066e6ea857935e74c10&#34;</ETag><Size>95476</Size><StorageClass>STANDARD</StorageClass></Contents><EncodingType>url</EncodingType></ListBucketResult>

this is the code is used to get the objects:

            .WithBucket(BUCKETNAME)
                .WithPrefix(null)
                .WithRecursive(true)
                .WithVersions(false);

        var photos = new List<Photo>();

        await foreach (var item in _minioClient.ListObjectsEnumAsync(listArgs))
        {

            photos.Add(new Photo
            {
                Src = item.Key,
                CreatedAt = item.LastModifiedDateTime,

            });

        }

I hope someone can figure out what's wrong here

davidlahuta commented 3 weeks ago

Any luck? How did you resolve this?