@@ -73,7 +73,7 @@ function getClient(params) {
73
73
return new S3Client ( clientConfig ) ;
74
74
}
75
75
76
- async function getObjMd ( params , cb ) {
76
+ function getObjMd ( params , cb ) {
77
77
const {
78
78
client,
79
79
bucket,
@@ -86,27 +86,26 @@ async function getObjMd(params, cb) {
86
86
return cb ( new Error ( errMsg ) ) ;
87
87
}
88
88
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
+ 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 ) ;
107
106
}
108
107
109
- async function listObjects ( params , cb ) {
108
+ function listObjects ( params , cb ) {
110
109
const {
111
110
client,
112
111
bucket,
@@ -124,19 +123,16 @@ async function listObjects(params, cb) {
124
123
return cb ( new Error ( errMsg ) ) ;
125
124
}
126
125
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
+ 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 ) ;
140
136
}
141
137
142
138
module . exports = {
0 commit comments