aws-v3-sdk 1.0.33 → 1.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/clients/all.js +0 -1
- package/clients/s3.js +25 -1
- package/es-handler/es-audits-wrapper.js +1 -1
- package/es-handler/es-wrapper.js +4 -16
- package/package.json +1 -1
- package/clients/s3R.js +0 -170
package/clients/all.js
CHANGED
package/clients/s3.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { S3Client, GetObjectCommand, PutObjectCommand, ListObjectsCommand, DeleteObjectsCommand, CreateMultipartUploadCommand, CompleteMultipartUploadCommand, UploadPartCommand } = require('@aws-sdk/client-s3')
|
|
1
|
+
const { S3Client, GetObjectCommand, PutObjectCommand, HeadObjectCommand, ListObjectsCommand, DeleteObjectsCommand, CreateMultipartUploadCommand, CompleteMultipartUploadCommand, UploadPartCommand } = require('@aws-sdk/client-s3')
|
|
2
2
|
const { getSignedUrl } = require('@aws-sdk/s3-request-presigner')
|
|
3
3
|
|
|
4
4
|
const { Agent } = require('https')
|
|
@@ -147,6 +147,30 @@ class S3 {
|
|
|
147
147
|
return Promise.reject(error)
|
|
148
148
|
})
|
|
149
149
|
}
|
|
150
|
+
|
|
151
|
+
headObject (params, callback) {
|
|
152
|
+
return new Promise((resolve, reject) => {
|
|
153
|
+
const headObject = new HeadObjectCommand(params)
|
|
154
|
+
client.send(headObject, (err, data) => {
|
|
155
|
+
if (err || !data) {
|
|
156
|
+
resolve(err)
|
|
157
|
+
}
|
|
158
|
+
if (data) {
|
|
159
|
+
resolve(data)
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
}).then(result => {
|
|
163
|
+
if (callback && typeof callback === 'function') {
|
|
164
|
+
callback(null, result)
|
|
165
|
+
}
|
|
166
|
+
return result
|
|
167
|
+
}).catch(error => {
|
|
168
|
+
if (callback && typeof callback === 'function') {
|
|
169
|
+
callback(error, null)
|
|
170
|
+
}
|
|
171
|
+
return Promise.reject(error)
|
|
172
|
+
})
|
|
173
|
+
}
|
|
150
174
|
}
|
|
151
175
|
|
|
152
176
|
module.exports = S3
|
package/es-handler/es-wrapper.js
CHANGED
|
@@ -28,8 +28,7 @@ const getClient = async () => {
|
|
|
28
28
|
const cred = createAwsConnector(credentials, REGION)
|
|
29
29
|
return new Client({
|
|
30
30
|
...cred,
|
|
31
|
-
node: host
|
|
32
|
-
maxRetries: 0
|
|
31
|
+
node: host
|
|
33
32
|
})
|
|
34
33
|
}
|
|
35
34
|
|
|
@@ -40,8 +39,7 @@ exports.sendReqToES = async (method, index, type, id, data) => {
|
|
|
40
39
|
const response = await client.delete({
|
|
41
40
|
index,
|
|
42
41
|
type,
|
|
43
|
-
id
|
|
44
|
-
refresh: false
|
|
42
|
+
id
|
|
45
43
|
})
|
|
46
44
|
return response.body
|
|
47
45
|
} else if (method === 'UPDATE') {
|
|
@@ -50,17 +48,7 @@ exports.sendReqToES = async (method, index, type, id, data) => {
|
|
|
50
48
|
index,
|
|
51
49
|
type,
|
|
52
50
|
body: data,
|
|
53
|
-
refresh:
|
|
54
|
-
retry_on_conflict: 10
|
|
55
|
-
})
|
|
56
|
-
return response.body
|
|
57
|
-
} else if (method === 'UPDATE_BY_QUERY') {
|
|
58
|
-
const response = await client.updateByQuery({
|
|
59
|
-
index,
|
|
60
|
-
type,
|
|
61
|
-
body: data,
|
|
62
|
-
refresh: false,
|
|
63
|
-
retry_on_conflict: 10
|
|
51
|
+
refresh: true
|
|
64
52
|
})
|
|
65
53
|
return response.body
|
|
66
54
|
} else {
|
|
@@ -69,7 +57,7 @@ exports.sendReqToES = async (method, index, type, id, data) => {
|
|
|
69
57
|
index,
|
|
70
58
|
type,
|
|
71
59
|
body: data,
|
|
72
|
-
refresh:
|
|
60
|
+
refresh: true
|
|
73
61
|
})
|
|
74
62
|
return response.body
|
|
75
63
|
}
|
package/package.json
CHANGED
package/clients/s3R.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
const { S3Client, GetObjectCommand, PutObjectCommand, ListObjectsCommand, DeleteObjectsCommand, CreateMultipartUploadCommand, CompleteMultipartUploadCommand, UploadPartCommand, ListObjectsV2Command } = require('@aws-sdk/client-s3')
|
|
2
|
-
const { getSignedUrl } = require('@aws-sdk/s3-request-presigner')
|
|
3
|
-
class S3R {
|
|
4
|
-
constructor (params) {
|
|
5
|
-
this.client = new S3Client(params)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
getSignedUrl (type, params, callback) {
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
if (type === 'getObject') {
|
|
11
|
-
const Expires = params.Expires
|
|
12
|
-
delete params.Expires
|
|
13
|
-
const command = new GetObjectCommand(params)
|
|
14
|
-
getSignedUrl(this.client, command, { expiresIn: Expires }).then(url => {
|
|
15
|
-
resolve(url)
|
|
16
|
-
}).catch(err => {
|
|
17
|
-
resolve(err)
|
|
18
|
-
})
|
|
19
|
-
} else if (type === 'putObject') {
|
|
20
|
-
const Expires = params.Expires
|
|
21
|
-
delete params.Expires
|
|
22
|
-
const command = new PutObjectCommand(params)
|
|
23
|
-
getSignedUrl(this.client, command, { expiresIn: Expires }).then(url => {
|
|
24
|
-
resolve(url)
|
|
25
|
-
}).catch(err => {
|
|
26
|
-
resolve(err)
|
|
27
|
-
})
|
|
28
|
-
} else if (type === 'uploadPart') {
|
|
29
|
-
const Expires = params.Expires
|
|
30
|
-
delete params.Expires
|
|
31
|
-
const command = new UploadPartCommand(params)
|
|
32
|
-
getSignedUrl(this.client, command, { expiresIn: Expires }).then(url => {
|
|
33
|
-
resolve(url)
|
|
34
|
-
}).catch(err => {
|
|
35
|
-
resolve(err)
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
}).then(result => {
|
|
39
|
-
if (callback && typeof callback === 'function') {
|
|
40
|
-
callback(null, result)
|
|
41
|
-
}
|
|
42
|
-
return result
|
|
43
|
-
}).catch(error => {
|
|
44
|
-
if (callback && typeof callback === 'function') {
|
|
45
|
-
callback(error, null)
|
|
46
|
-
}
|
|
47
|
-
return Promise.reject(error)
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
createMultipartUpload (params, callback) {
|
|
52
|
-
return new Promise((resolve, reject) => {
|
|
53
|
-
const command = new CreateMultipartUploadCommand(params)
|
|
54
|
-
this.client.send(command).then(response => {
|
|
55
|
-
resolve(response)
|
|
56
|
-
}).catch(err => {
|
|
57
|
-
reject(err)
|
|
58
|
-
})
|
|
59
|
-
}).then(result => {
|
|
60
|
-
if (callback && typeof callback === 'function') {
|
|
61
|
-
callback(null, result)
|
|
62
|
-
}
|
|
63
|
-
return result
|
|
64
|
-
}).catch(error => {
|
|
65
|
-
if (callback && typeof callback === 'function') {
|
|
66
|
-
callback(error, null)
|
|
67
|
-
}
|
|
68
|
-
return Promise.reject(error)
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
completeMultipartUpload (params, callback) {
|
|
73
|
-
return new Promise((resolve, reject) => {
|
|
74
|
-
const command = new CompleteMultipartUploadCommand(params)
|
|
75
|
-
this.client.send(command).then(response => {
|
|
76
|
-
resolve(response)
|
|
77
|
-
}).catch(err => {
|
|
78
|
-
resolve(err)
|
|
79
|
-
})
|
|
80
|
-
}).then(result => {
|
|
81
|
-
if (callback && typeof callback === 'function') {
|
|
82
|
-
callback(null, result)
|
|
83
|
-
}
|
|
84
|
-
return result
|
|
85
|
-
}).catch(error => {
|
|
86
|
-
if (callback && typeof callback === 'function') {
|
|
87
|
-
callback(error, null)
|
|
88
|
-
}
|
|
89
|
-
return Promise.reject(error)
|
|
90
|
-
})
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
getObject (params, callback) {
|
|
94
|
-
return new Promise((resolve, reject) => {
|
|
95
|
-
const getObject = new GetObjectCommand(params)
|
|
96
|
-
this.client.send(getObject).then(response => {
|
|
97
|
-
const chunks = []
|
|
98
|
-
const stream = response.Body
|
|
99
|
-
stream.on('data', chunk => chunks.push(chunk))
|
|
100
|
-
stream.on('end', () => {
|
|
101
|
-
const imageBuffer = Buffer.concat(chunks)
|
|
102
|
-
response.Body = imageBuffer
|
|
103
|
-
resolve(response)
|
|
104
|
-
})
|
|
105
|
-
}).catch(err => {
|
|
106
|
-
resolve(err)
|
|
107
|
-
})
|
|
108
|
-
}).then(result => {
|
|
109
|
-
if (callback && typeof callback === 'function') {
|
|
110
|
-
callback(null, result)
|
|
111
|
-
}
|
|
112
|
-
return result
|
|
113
|
-
}).catch(error => {
|
|
114
|
-
if (callback && typeof callback === 'function') {
|
|
115
|
-
callback(error, null)
|
|
116
|
-
}
|
|
117
|
-
return Promise.reject(error)
|
|
118
|
-
})
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
putObject (params, callback) {
|
|
122
|
-
return new Promise((resolve, reject) => {
|
|
123
|
-
const putObject = new PutObjectCommand(params)
|
|
124
|
-
this.client.send(putObject, (err, data) => {
|
|
125
|
-
if (err || !data) {
|
|
126
|
-
resolve(err)
|
|
127
|
-
}
|
|
128
|
-
if (data) {
|
|
129
|
-
resolve(data)
|
|
130
|
-
}
|
|
131
|
-
})
|
|
132
|
-
}).then(result => {
|
|
133
|
-
if (callback && typeof callback === 'function') {
|
|
134
|
-
callback(null, result)
|
|
135
|
-
}
|
|
136
|
-
return result
|
|
137
|
-
}).catch(error => {
|
|
138
|
-
if (callback && typeof callback === 'function') {
|
|
139
|
-
callback(error, null)
|
|
140
|
-
}
|
|
141
|
-
return Promise.reject(error)
|
|
142
|
-
})
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
listObjectsV2 (params, callback) {
|
|
146
|
-
return new Promise((resolve, reject) => {
|
|
147
|
-
const command = new ListObjectsV2Command(params)
|
|
148
|
-
this.client.send(command, (err, data) => {
|
|
149
|
-
if (err || !data) {
|
|
150
|
-
resolve(err)
|
|
151
|
-
}
|
|
152
|
-
if (data) {
|
|
153
|
-
resolve(data)
|
|
154
|
-
}
|
|
155
|
-
})
|
|
156
|
-
}).then(result => {
|
|
157
|
-
if (callback && typeof callback === 'function') {
|
|
158
|
-
callback(null, result)
|
|
159
|
-
}
|
|
160
|
-
return result
|
|
161
|
-
}).catch(error => {
|
|
162
|
-
if (callback && typeof callback === 'function') {
|
|
163
|
-
callback(error, null)
|
|
164
|
-
}
|
|
165
|
-
return Promise.reject(error)
|
|
166
|
-
})
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
module.exports = S3R
|