How to list object using delimeter and sort_by in aws s3 api?

Multi tool use
How to list object using delimeter and sort_by in aws s3 api?
I used below command to list object using delimeter to print second level folder only -
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --delimiter "/"
COMMONPREFIXES firstlevelfolder1/
COMMONPREFIXES firstlevelfolder2/
It worked fine and print second level folders based on prefix that I passed.
And I used below command to list the objects based on last modified date.
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --query 'sort_by(Contents,&LastModified)[*].[Key,LastModified]'
firstlevelfolder1/ 2018-12-28T11:41:07.000Z
firstlevelfolder2/ 2018-12-28T11:41:18.000Z
firstlevelfolder1/secondlevelfolder1/ 2018-12-28T11:41:30.000Z
firstlevelfolder2/secondlevelfolder2/ 2018-12-28T11:41:43.000Z
firstlevelfolder1/secondlevelfolder1/test.java 2018-12-28T11:42:28.000Z
firstlevelfolder2/secondlevelfolder2/test.java 2018-12-28T11:42:46.000Z
it worked fine and print the objects sorted by time.
But when I tried to combine both the command I got error -
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --query 'sort_by(Contents,&LastModified)[*].[Key,LastModified]' --delimiter "/"
In function sort_by(), invalid type for value: None, expected one of: ['array'], received: "null"
amazon-web-services amazon-s3 aws-cli
add a comment |
How to list object using delimeter and sort_by in aws s3 api?
I used below command to list object using delimeter to print second level folder only -
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --delimiter "/"
COMMONPREFIXES firstlevelfolder1/
COMMONPREFIXES firstlevelfolder2/
It worked fine and print second level folders based on prefix that I passed.
And I used below command to list the objects based on last modified date.
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --query 'sort_by(Contents,&LastModified)[*].[Key,LastModified]'
firstlevelfolder1/ 2018-12-28T11:41:07.000Z
firstlevelfolder2/ 2018-12-28T11:41:18.000Z
firstlevelfolder1/secondlevelfolder1/ 2018-12-28T11:41:30.000Z
firstlevelfolder2/secondlevelfolder2/ 2018-12-28T11:41:43.000Z
firstlevelfolder1/secondlevelfolder1/test.java 2018-12-28T11:42:28.000Z
firstlevelfolder2/secondlevelfolder2/test.java 2018-12-28T11:42:46.000Z
it worked fine and print the objects sorted by time.
But when I tried to combine both the command I got error -
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --query 'sort_by(Contents,&LastModified)[*].[Key,LastModified]' --delimiter "/"
In function sort_by(), invalid type for value: None, expected one of: ['array'], received: "null"
amazon-web-services amazon-s3 aws-cli
add a comment |
How to list object using delimeter and sort_by in aws s3 api?
I used below command to list object using delimeter to print second level folder only -
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --delimiter "/"
COMMONPREFIXES firstlevelfolder1/
COMMONPREFIXES firstlevelfolder2/
It worked fine and print second level folders based on prefix that I passed.
And I used below command to list the objects based on last modified date.
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --query 'sort_by(Contents,&LastModified)[*].[Key,LastModified]'
firstlevelfolder1/ 2018-12-28T11:41:07.000Z
firstlevelfolder2/ 2018-12-28T11:41:18.000Z
firstlevelfolder1/secondlevelfolder1/ 2018-12-28T11:41:30.000Z
firstlevelfolder2/secondlevelfolder2/ 2018-12-28T11:41:43.000Z
firstlevelfolder1/secondlevelfolder1/test.java 2018-12-28T11:42:28.000Z
firstlevelfolder2/secondlevelfolder2/test.java 2018-12-28T11:42:46.000Z
it worked fine and print the objects sorted by time.
But when I tried to combine both the command I got error -
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --query 'sort_by(Contents,&LastModified)[*].[Key,LastModified]' --delimiter "/"
In function sort_by(), invalid type for value: None, expected one of: ['array'], received: "null"
amazon-web-services amazon-s3 aws-cli
How to list object using delimeter and sort_by in aws s3 api?
I used below command to list object using delimeter to print second level folder only -
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --delimiter "/"
COMMONPREFIXES firstlevelfolder1/
COMMONPREFIXES firstlevelfolder2/
It worked fine and print second level folders based on prefix that I passed.
And I used below command to list the objects based on last modified date.
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --query 'sort_by(Contents,&LastModified)[*].[Key,LastModified]'
firstlevelfolder1/ 2018-12-28T11:41:07.000Z
firstlevelfolder2/ 2018-12-28T11:41:18.000Z
firstlevelfolder1/secondlevelfolder1/ 2018-12-28T11:41:30.000Z
firstlevelfolder2/secondlevelfolder2/ 2018-12-28T11:41:43.000Z
firstlevelfolder1/secondlevelfolder1/test.java 2018-12-28T11:42:28.000Z
firstlevelfolder2/secondlevelfolder2/test.java 2018-12-28T11:42:46.000Z
it worked fine and print the objects sorted by time.
But when I tried to combine both the command I got error -
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --query 'sort_by(Contents,&LastModified)[*].[Key,LastModified]' --delimiter "/"
In function sort_by(), invalid type for value: None, expected one of: ['array'], received: "null"
amazon-web-services amazon-s3 aws-cli
amazon-web-services amazon-s3 aws-cli
edited 15 hours ago
asked yesterday


VIPIN KUMAR
2,042919
2,042919
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Your command is probably returning 0 objects (None
value here) but the sort_by
method will expect an array
Check if this returns objects or not:
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --delimiter "/"
If this does not then that's your issue.
Thanks for checking on my question @sanster_23, the command given by you is same which I used in my question and it prints the result and the second command that I used without delimeter also worked fine to sort the objects but when I useddelimiter
andsort_by
it didn't work.
– VIPIN KUMAR
yesterday
@VIPINKUMAR when you get only folders in the list that means - you have a list of object prefixes like (f1/, f2/) etc. these do not have a LastModified field. only Objects do.
– sanster_23
yesterday
@VIPINKUMAR did it work?
– sanster_23
20 hours ago
I have updated my question with output to make it more clear and I can see every level object have lastmodified time.
– VIPIN KUMAR
15 hours ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53943996%2fhow-to-list-object-using-delimeter-and-sort-by-in-aws-s3-api%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your command is probably returning 0 objects (None
value here) but the sort_by
method will expect an array
Check if this returns objects or not:
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --delimiter "/"
If this does not then that's your issue.
Thanks for checking on my question @sanster_23, the command given by you is same which I used in my question and it prints the result and the second command that I used without delimeter also worked fine to sort the objects but when I useddelimiter
andsort_by
it didn't work.
– VIPIN KUMAR
yesterday
@VIPINKUMAR when you get only folders in the list that means - you have a list of object prefixes like (f1/, f2/) etc. these do not have a LastModified field. only Objects do.
– sanster_23
yesterday
@VIPINKUMAR did it work?
– sanster_23
20 hours ago
I have updated my question with output to make it more clear and I can see every level object have lastmodified time.
– VIPIN KUMAR
15 hours ago
add a comment |
Your command is probably returning 0 objects (None
value here) but the sort_by
method will expect an array
Check if this returns objects or not:
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --delimiter "/"
If this does not then that's your issue.
Thanks for checking on my question @sanster_23, the command given by you is same which I used in my question and it prints the result and the second command that I used without delimeter also worked fine to sort the objects but when I useddelimiter
andsort_by
it didn't work.
– VIPIN KUMAR
yesterday
@VIPINKUMAR when you get only folders in the list that means - you have a list of object prefixes like (f1/, f2/) etc. these do not have a LastModified field. only Objects do.
– sanster_23
yesterday
@VIPINKUMAR did it work?
– sanster_23
20 hours ago
I have updated my question with output to make it more clear and I can see every level object have lastmodified time.
– VIPIN KUMAR
15 hours ago
add a comment |
Your command is probably returning 0 objects (None
value here) but the sort_by
method will expect an array
Check if this returns objects or not:
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --delimiter "/"
If this does not then that's your issue.
Your command is probably returning 0 objects (None
value here) but the sort_by
method will expect an array
Check if this returns objects or not:
aws s3api list-objects-v2 --bucket $bucketNameToUse --prefix $prefixToUse --output text --delimiter "/"
If this does not then that's your issue.
answered yesterday


sanster_23
156311
156311
Thanks for checking on my question @sanster_23, the command given by you is same which I used in my question and it prints the result and the second command that I used without delimeter also worked fine to sort the objects but when I useddelimiter
andsort_by
it didn't work.
– VIPIN KUMAR
yesterday
@VIPINKUMAR when you get only folders in the list that means - you have a list of object prefixes like (f1/, f2/) etc. these do not have a LastModified field. only Objects do.
– sanster_23
yesterday
@VIPINKUMAR did it work?
– sanster_23
20 hours ago
I have updated my question with output to make it more clear and I can see every level object have lastmodified time.
– VIPIN KUMAR
15 hours ago
add a comment |
Thanks for checking on my question @sanster_23, the command given by you is same which I used in my question and it prints the result and the second command that I used without delimeter also worked fine to sort the objects but when I useddelimiter
andsort_by
it didn't work.
– VIPIN KUMAR
yesterday
@VIPINKUMAR when you get only folders in the list that means - you have a list of object prefixes like (f1/, f2/) etc. these do not have a LastModified field. only Objects do.
– sanster_23
yesterday
@VIPINKUMAR did it work?
– sanster_23
20 hours ago
I have updated my question with output to make it more clear and I can see every level object have lastmodified time.
– VIPIN KUMAR
15 hours ago
Thanks for checking on my question @sanster_23, the command given by you is same which I used in my question and it prints the result and the second command that I used without delimeter also worked fine to sort the objects but when I used
delimiter
and sort_by
it didn't work.– VIPIN KUMAR
yesterday
Thanks for checking on my question @sanster_23, the command given by you is same which I used in my question and it prints the result and the second command that I used without delimeter also worked fine to sort the objects but when I used
delimiter
and sort_by
it didn't work.– VIPIN KUMAR
yesterday
@VIPINKUMAR when you get only folders in the list that means - you have a list of object prefixes like (f1/, f2/) etc. these do not have a LastModified field. only Objects do.
– sanster_23
yesterday
@VIPINKUMAR when you get only folders in the list that means - you have a list of object prefixes like (f1/, f2/) etc. these do not have a LastModified field. only Objects do.
– sanster_23
yesterday
@VIPINKUMAR did it work?
– sanster_23
20 hours ago
@VIPINKUMAR did it work?
– sanster_23
20 hours ago
I have updated my question with output to make it more clear and I can see every level object have lastmodified time.
– VIPIN KUMAR
15 hours ago
I have updated my question with output to make it more clear and I can see every level object have lastmodified time.
– VIPIN KUMAR
15 hours ago
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53943996%2fhow-to-list-object-using-delimeter-and-sort-by-in-aws-s3-api%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
j6SjDa639NYozxJBTg8ua2ra931J