mobiletto-driver-s3 1.0.0 → 1.0.2
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/drivers/s3/index.js +6 -21
- package/package.json +7 -20
package/drivers/s3/index.js
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
const {
|
|
2
2
|
M_DIR, M_FILE,
|
|
3
3
|
MobilettoError, MobilettoNotFoundError, readStream
|
|
4
|
-
} = require('
|
|
5
|
-
|
|
6
|
-
let log = {
|
|
7
|
-
debug: s => { console.log(s) }
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
const { logger } = require('../../util/logger')
|
|
12
|
-
log = logger
|
|
13
|
-
} catch (e) {
|
|
14
|
-
log.debug(`s3 driver logger init failed: ${e}`)
|
|
15
|
-
}
|
|
4
|
+
} = require('mobiletto-common')
|
|
16
5
|
|
|
17
6
|
const { dirname } = require('path')
|
|
18
7
|
|
|
@@ -106,7 +95,7 @@ class StorageClient {
|
|
|
106
95
|
}
|
|
107
96
|
const objects = []
|
|
108
97
|
let objectCount = 0
|
|
109
|
-
|
|
98
|
+
logger.debug(`${logPrefix} bucketParams=${JSON.stringify(bucketParams)}`)
|
|
110
99
|
|
|
111
100
|
// while loop that runs until 'response.truncated' is false.
|
|
112
101
|
while (truncated) {
|
|
@@ -221,7 +210,7 @@ class StorageClient {
|
|
|
221
210
|
})
|
|
222
211
|
let total = 0
|
|
223
212
|
uploader.on('httpUploadProgress', (progress) => {
|
|
224
|
-
|
|
213
|
+
logger.debug(`write(${bucketParams.Key}) ${JSON.stringify(progress)}`)
|
|
225
214
|
total += progress.loaded
|
|
226
215
|
})
|
|
227
216
|
const response = await uploader.done()
|
|
@@ -233,7 +222,7 @@ class StorageClient {
|
|
|
233
222
|
|
|
234
223
|
async read (path, callback, endCallback = null) {
|
|
235
224
|
const Key = this.normalizeKey(path)
|
|
236
|
-
|
|
225
|
+
logger.debug(`read: reading Key: ${path} - ${Key}`)
|
|
237
226
|
const bucketParams = {
|
|
238
227
|
Region: this.region,
|
|
239
228
|
Bucket: this.bucket,
|
|
@@ -264,7 +253,7 @@ class StorageClient {
|
|
|
264
253
|
Bucket: this.bucket,
|
|
265
254
|
Delete
|
|
266
255
|
}
|
|
267
|
-
|
|
256
|
+
logger.debug(`remove(${path}) deleting objects: ${JSON.stringify(objects)}`)
|
|
268
257
|
const response = await this.client.send(new DeleteObjectsCommand(bucketParams))
|
|
269
258
|
let statusCode = response.$metadata.httpStatusCode
|
|
270
259
|
let statusClass = Math.floor(statusCode / 100)
|
|
@@ -322,8 +311,4 @@ function storageClient (key, secret, opts) {
|
|
|
322
311
|
return new StorageClient(key, secret, opts)
|
|
323
312
|
}
|
|
324
313
|
|
|
325
|
-
|
|
326
|
-
log = logger
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
module.exports = { storageClient, setLogger }
|
|
314
|
+
module.exports = { storageClient }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobiletto-driver-s3",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "The s3 driver for mobiletto. This package is intended to be used with mobiletto-base, which does not include any drivers",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -21,27 +21,14 @@
|
|
|
21
21
|
"url": "https://github.com/cobbzilla/mobiletto"
|
|
22
22
|
},
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
|
-
"scripts": {
|
|
25
|
-
"test": "mocha --timeout 60000 ./test/*.spec.js"
|
|
26
|
-
},
|
|
27
24
|
"devDependencies": {
|
|
28
|
-
"@babel/core": "^7.
|
|
29
|
-
"@babel/node": "^7.
|
|
30
|
-
"@babel/preset-env": "^7.
|
|
31
|
-
"chai": "^4.3.6",
|
|
32
|
-
"dotenv": "^16.0.1",
|
|
33
|
-
"mocha": "^10.0.0",
|
|
34
|
-
"randomstring": "^1.2.2"
|
|
25
|
+
"@babel/core": "^7.22.5",
|
|
26
|
+
"@babel/node": "^7.22.5",
|
|
27
|
+
"@babel/preset-env": "^7.22.5"
|
|
35
28
|
},
|
|
36
29
|
"dependencies": {
|
|
37
|
-
"@aws-sdk/client-s3": "^3.
|
|
38
|
-
"@aws-sdk/lib-storage": "^3.
|
|
39
|
-
"
|
|
40
|
-
"ioredis": "^5.2.3",
|
|
41
|
-
"lru-cache": "^7.14.0",
|
|
42
|
-
"node-fetch-commonjs": "^3.1.1",
|
|
43
|
-
"node-redis-scan": "^1.3.5",
|
|
44
|
-
"shasum": "^1.0.2",
|
|
45
|
-
"winston": "^3.8.1"
|
|
30
|
+
"@aws-sdk/client-s3": "^3.359.0",
|
|
31
|
+
"@aws-sdk/lib-storage": "^3.359.0",
|
|
32
|
+
"mobiletto-common": "^1.0.1"
|
|
46
33
|
}
|
|
47
34
|
}
|