@@ -73,7 +73,7 @@ function getClient(params) {
7373 return new S3Client ( clientConfig ) ;
7474}
7575
76- async function getObjMd ( params , cb ) {
76+ function getObjMd ( params , cb ) {
7777 const {
7878 client,
7979 bucket,
@@ -86,27 +86,26 @@ async function getObjMd(params, cb) {
8686 return cb ( new Error ( errMsg ) ) ;
8787 }
8888
89- try {
90- const commandParams = {
91- Bucket : bucket ,
92- Key : key ,
93- VersionId : versionId
94- } ;
95-
96- const data = await client . send ( new HeadObjectCommand ( commandParams ) ) ;
97- const resp = {
98- size : data . ContentLength ,
99- lastModified : data . LastModified ,
100- versionId : data . VersionId ,
101- md : data . Metadata ,
102- } ;
103- return cb ( null , resp ) ;
104- } catch ( err ) {
105- return cb ( err ) ;
106- }
89+ const commandParams = {
90+ Bucket : bucket ,
91+ Key : key ,
92+ VersionId : versionId
93+ } ;
94+
95+ return client . send ( new HeadObjectCommand ( commandParams ) )
96+ . then ( data => {
97+ const resp = {
98+ size : data . ContentLength ,
99+ lastModified : data . LastModified ,
100+ versionId : data . VersionId ,
101+ md : data . Metadata ,
102+ } ;
103+ return cb ( null , resp ) ;
104+ } )
105+ . catch ( cb ) ;
107106}
108107
109- async function listObjects ( params , cb ) {
108+ function listObjects ( params , cb ) {
110109 const {
111110 client,
112111 bucket,
@@ -124,19 +123,16 @@ async function listObjects(params, cb) {
124123 return cb ( new Error ( errMsg ) ) ;
125124 }
126125
127- try {
128- // TODO: support listing all versions
129- const data = await client . send ( new ListObjectsV2Command ( {
130- Bucket : bucket ,
131- MaxKeys : listingLimit ,
132- Prefix : prefix ,
133- Delimiter : delimiter ,
134- ContinuationToken : nextContinuationToken ,
135- } ) ) ;
136- return cb ( null , data ) ;
137- } catch ( err ) {
138- return cb ( err ) ;
139- }
126+ // TODO: support listing all versions
127+ return client . send ( new ListObjectsV2Command ( {
128+ Bucket : bucket ,
129+ MaxKeys : listingLimit ,
130+ Prefix : prefix ,
131+ Delimiter : delimiter ,
132+ ContinuationToken : nextContinuationToken ,
133+ } ) )
134+ . then ( data => cb ( null , data ) )
135+ . catch ( cb ) ;
140136}
141137
142138module . exports = {
0 commit comments