ERROR: xmlobj.CommonPrefixes.forEach is not a function
See original GitHub issueminio version:^7.0.17
found this problem when I used the listobjects API
1、When the third parameter recursive of listobjects is set to true, the result returned is correct
// code
const bucketName = params.bucketName || '';
const prefix = params.prefix || '';
const stream = app.minio.listObjects(bucketName, prefix, true);
return new Promise(resolve => {
const res = [];
stream.on('data', obj => {
res.push(obj);
});
stream.on('end', () => {
resolve({
code: 0,
data: res,
});
});
stream.on('error', err => {
resolve({
code: 1,
msg: err,
});
});
});
// result
[
{
"name":"child/aa.txt",
"lastModified":"2020-12-01T04:04:18.148Z",
"etag":"166bcae2d953f92b1fa3b40d218d2a38",
"size":57
},
{
"name":"bb.jpg",
"lastModified":"2020-12-01T02:39:41.026Z",
"etag":"ba02b3771a3ceeaf1d4925c62d05780b",
"size":8730
},
{
"name":"cc.jpg",
"lastModified":"2020-12-01T02:40:21.905Z",
"etag":"aed69181e64900aeaaf4b18798c7bcc4",
"size":10891
}
]
2、However, when the third parameter recursive is set to false, an error is reported
// code
app.minio.listObjects(bucketName, prefix, false);
......
// result
ERROR: xmlobj.CommonPrefixes.forEach is not a function
I entered the wrong node_ modules\minio\dist\main\xml- parsers.js:381 : 27 files, printing xmlobj.CommonPrefixes The results are as follows:
// Error source code
if (xmlobj.CommonPrefixes) {
console.log('xmlobj.CommonPrefixes', xmlobj.CommonPrefixes);
xmlobj.CommonPrefixes.forEach(function (commonPrefix) {
var prefix = commonPrefix.Prefix[0];
var size = 0;
result.objects.push({
prefix,
size
});
});
}
// console.log result
xmlobj.CommonPrefixes { Prefix: 'child/' }
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:12 (6 by maintainers)
Top Results From Across the Web
forEach is not a function error with JavaScript array
First option: invoke forEach indirectly. The parent.children is an Array like object. Use the following solution: const parent = this.el.
Read more >Fix Uncaught TypeError: forEach is not a function Error in ...
The JavaScript "forEach is not a function" error occurs when you call the method 'forEach()' on a variable or property that's not of...
Read more >minio - Bountysource
Hi guys, I get a very strange error every time I call the statObject method of the ... forEach is not a function...
Read more >Viewing online file analysis results for 'mongodumpxp.exe'
Name Ordinal Address
??0Arg@pcrecpp@@QAE@PAD@Z #1 0x479fc0
??0Arg@pcrecpp@@QAE@PADP6A_NPBDHPAX@Z@Z #2 0x47a0e0
??0Arg@pcrecpp@@QAE@PAE@Z #3 0x479fc0
Read more >vocab.txt - Hugging Face
... read ##roup ##ple has check elif ##ory ##ib ##ger ##ersion function end ... provid ##cket ##pace dep descri ##not bin ph callback...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mitni455 i just had the same issue, and avoided the error using listObjectsV2
Thank you @mitni455 for the information. Thank you @prakashsvmx for replying. This fix and quite some API support changes are on the way to be released. Please stay tuned.