mobiletto 1.2.1 → 2.0.1

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.
Files changed (124) hide show
  1. package/lib/cjs/index.d.ts +2 -0
  2. package/lib/cjs/index.js +30 -0
  3. package/lib/cjs/package.json +16 -0
  4. package/lib/esm/index.d.ts +2 -0
  5. package/lib/esm/index.js +12 -0
  6. package/package.json +27 -13
  7. package/.babelrc +0 -5
  8. package/.eslintrc.js +0 -14
  9. package/docs/README.md +0 -113
  10. package/docs/af/README.md +0 -481
  11. package/docs/am/README.md +0 -481
  12. package/docs/ar/README.md +0 -481
  13. package/docs/az/README.md +0 -481
  14. package/docs/be/README.md +0 -481
  15. package/docs/bg/README.md +0 -481
  16. package/docs/bn/README.md +0 -481
  17. package/docs/bs/README.md +0 -481
  18. package/docs/ca/README.md +0 -481
  19. package/docs/ceb/README.md +0 -481
  20. package/docs/co/README.md +0 -481
  21. package/docs/cs/README.md +0 -481
  22. package/docs/cy/README.md +0 -481
  23. package/docs/da/README.md +0 -481
  24. package/docs/de/README.md +0 -481
  25. package/docs/el/README.md +0 -481
  26. package/docs/eo/README.md +0 -481
  27. package/docs/es/README.md +0 -481
  28. package/docs/et/README.md +0 -481
  29. package/docs/eu/README.md +0 -481
  30. package/docs/fa/README.md +0 -481
  31. package/docs/fi/README.md +0 -481
  32. package/docs/fr/README.md +0 -481
  33. package/docs/fy/README.md +0 -481
  34. package/docs/ga/README.md +0 -481
  35. package/docs/gd/README.md +0 -481
  36. package/docs/gl/README.md +0 -481
  37. package/docs/gu/README.md +0 -481
  38. package/docs/ha/README.md +0 -481
  39. package/docs/haw/README.md +0 -481
  40. package/docs/he/README.md +0 -481
  41. package/docs/hi/README.md +0 -481
  42. package/docs/hmn/README.md +0 -481
  43. package/docs/hr/README.md +0 -481
  44. package/docs/ht/README.md +0 -481
  45. package/docs/hu/README.md +0 -481
  46. package/docs/hy/README.md +0 -481
  47. package/docs/id/README.md +0 -481
  48. package/docs/ig/README.md +0 -481
  49. package/docs/is/README.md +0 -481
  50. package/docs/it/README.md +0 -481
  51. package/docs/iw/README.md +0 -481
  52. package/docs/ja/README.md +0 -481
  53. package/docs/jv/README.md +0 -481
  54. package/docs/ka/README.md +0 -481
  55. package/docs/kk/README.md +0 -481
  56. package/docs/km/README.md +0 -481
  57. package/docs/kn/README.md +0 -481
  58. package/docs/ko/README.md +0 -481
  59. package/docs/ku/README.md +0 -481
  60. package/docs/ky/README.md +0 -481
  61. package/docs/la/README.md +0 -481
  62. package/docs/lb/README.md +0 -481
  63. package/docs/lo/README.md +0 -481
  64. package/docs/lt/README.md +0 -481
  65. package/docs/lv/README.md +0 -481
  66. package/docs/mg/README.md +0 -481
  67. package/docs/mi/README.md +0 -481
  68. package/docs/mk/README.md +0 -481
  69. package/docs/ml/README.md +0 -481
  70. package/docs/mn/README.md +0 -481
  71. package/docs/mr/README.md +0 -481
  72. package/docs/ms/README.md +0 -481
  73. package/docs/mt/README.md +0 -481
  74. package/docs/my/README.md +0 -481
  75. package/docs/ne/README.md +0 -481
  76. package/docs/nl/README.md +0 -481
  77. package/docs/no/README.md +0 -481
  78. package/docs/ny/README.md +0 -481
  79. package/docs/or/README.md +0 -481
  80. package/docs/pa/README.md +0 -481
  81. package/docs/pl/README.md +0 -481
  82. package/docs/ps/README.md +0 -481
  83. package/docs/pt/README.md +0 -481
  84. package/docs/ro/README.md +0 -481
  85. package/docs/ru/README.md +0 -481
  86. package/docs/rw/README.md +0 -481
  87. package/docs/sd/README.md +0 -481
  88. package/docs/si/README.md +0 -481
  89. package/docs/sk/README.md +0 -481
  90. package/docs/sl/README.md +0 -481
  91. package/docs/sm/README.md +0 -481
  92. package/docs/sn/README.md +0 -481
  93. package/docs/so/README.md +0 -481
  94. package/docs/sq/README.md +0 -481
  95. package/docs/sr/README.md +0 -481
  96. package/docs/st/README.md +0 -481
  97. package/docs/su/README.md +0 -481
  98. package/docs/sv/README.md +0 -481
  99. package/docs/sw/README.md +0 -481
  100. package/docs/ta/README.md +0 -481
  101. package/docs/te/README.md +0 -481
  102. package/docs/tg/README.md +0 -481
  103. package/docs/th/README.md +0 -481
  104. package/docs/tk/README.md +0 -481
  105. package/docs/tl/README.md +0 -481
  106. package/docs/tr/README.md +0 -481
  107. package/docs/tt/README.md +0 -481
  108. package/docs/ug/README.md +0 -481
  109. package/docs/uk/README.md +0 -481
  110. package/docs/ur/README.md +0 -481
  111. package/docs/uz/README.md +0 -481
  112. package/docs/vi/README.md +0 -481
  113. package/docs/xh/README.md +0 -481
  114. package/docs/yi/README.md +0 -481
  115. package/docs/yo/README.md +0 -481
  116. package/docs/zh/README.md +0 -481
  117. package/docs/zu/README.md +0 -481
  118. package/drivers/b2/index.js +0 -451
  119. package/drivers/local/index.js +0 -315
  120. package/drivers/s3/index.js +0 -316
  121. package/hokey.json +0 -16
  122. package/index.js +0 -29
  123. package/test/api.spec.js +0 -512
  124. package/test/crypt.spec.js +0 -67
@@ -1,481 +0,0 @@
1
- Mobiletto
2
- =========
3
-
4
- Mobiletto yog ib txheej JavaScript cia abstraction txheej, nrog kev xaiv pob tshab tus neeg siv sab encryption.
5
-
6
- # Cov ntsiab lus
7
- * [Vim li cas Mobiletto?](#Why-Mobiletto?)
8
- * [Quick start](#Quick-start)
9
- * [Mobiletto CLI](#mobiletto-cli)
10
- * [Source](#Source)
11
- * [Installation](#Installation)
12
- * [Support thiab Funding](#Support-and-Funding)
13
- * [Basic siv](#Basic-siv)
14
- * [Metadata](#Metadata)
15
- * [Lwm hom ntshuam](#Alternate-import-style)
16
- * [Caching](#Caching)
17
- * [Daim iav](# Mirroring)
18
- * [Transparent encryption](#Transparent-encryption)
19
- * [Key rotation](#Key-rotation)
20
- * [Driver interface](#Driver-interface)
21
- * [Logging](#Logging)
22
-
23
- # Nyeem qhov no ua lwm hom lus
24
- Cov ntaub ntawv README.md no tau raug muab txhais, ntawm [hokeylization](https://github.com/cobbzilla/hokeylization), rau hauv
25
- **[txhua hom lus txhawb nqa los ntawm Google Txhais](https://cloud.google.com/translate/docs/languages)!**
26
-
27
- Kuv paub tseeb tias nws tsis zoo tag nrho, tab sis kuv vam tias nws zoo dua tsis muaj dab tsi!
28
-
29
- [🇸🇦 Arabic](../ar/README.md)
30
- [🇧🇩 Bengali](../bn/README.md)
31
- [🇩🇪 German](../de/README.md)
32
- [🇺🇸 English](../en/README.md)
33
- [🇪🇸 Spanish](../es/README.md)
34
- [🇫🇷 Fab Kis](../fr/README.md)
35
- [🇹🇩 Hausa](../ha/README.md)
36
- [🇮🇳 Hindi](../hi/README.md)
37
- [🇮🇩 Indonesian](../id/README.md)
38
- [🇮🇹 Italian](../it/README.md)
39
- [🇯🇵 Nyiv](../ja/README.md)
40
- [🇰🇷 Korean](../ko/README.md)
41
- [🇮🇳 Marathi](../mr/README.md)
42
- [🇵🇱 Polish](../pl/README.md)
43
- [🇧🇷 Portuguese](../pt/README.md)
44
- [🇷🇺 Russian](../ru/README.md)
45
- [🇰🇪 Swahili](../sw/README.md)
46
- [🇵🇭 Tagalog](../tl/README.md)
47
- [🇹🇷 Turkish](../tr/README.md)
48
- [🇵🇰 Urdu](../ur/README.md)
49
- [🇻🇳 Nyab Laj](../vi/README.md)
50
- [🇨🇳 Suav](../zh/README.md)
51
-
52
-
53
- **[📚...Txhua Yam Lus...](../README.md)**
54
- ----
55
-
56
- ### Puas muaj teeb meem nrog qhov kev txhais lus ntawm README?
57
- Qhov kev txhais lus tshwj xeeb ntawm tus thawj [README](https://github.com/cobbzilla/mobiletto/blob/master/README.md)
58
- tej zaum yuav muaj qhov tsis txaus ntseeg -- * kho tau zoo siab txais tos!* Thov xa [rub thov ntawm GitHub](https://github.com/cobbzilla/mobiletto/pulls),
59
- lossis yog tias koj tsis xis nyob ua qhov ntawd, [qhib qhov teeb meem](https://github.com/cobbzilla/mobiletto/issues)
60
-
61
- Thaum koj tsim qhov teeb meem tshiab GitHub txog kev txhais lus, thov ua:
62
- * suav nrog nplooj URL (copy / paste los ntawm browser chaw nyob bar)
63
- * suav nrog cov ntawv tseeb uas tsis yog (copy / paste los ntawm browser)
64
- * thov piav qhia qhov tsis raug - puas yog kev txhais lus tsis raug? yog formatting puas lawm?
65
- * Ua siab zoo muab cov lus pom zoo ntawm kev txhais lus zoo dua, lossis yuav ua li cas cov ntawv yuav tsum raug formatted kom raug
66
- ** Ua tsaug!**
67
-
68
- ## Vim li cas Mobiletto?
69
-
70
- ### Nyob zoo tus neeg muag khoom xauv-hauv!
71
- Cov chaw muab huab cia ntau yam muaj qhov tsis sib xws APIs. Txawm tias cov uas siv zog rau "S3 compatibility"
72
- muaj tus cwj pwm idiosyncratic.
73
-
74
- Thaum koj xaiv ib lub chaw muag khoom tshwj xeeb rau koj lub app, yog tias koj code ncaj qha rau lawv API, koj lub app
75
- tam sim no nyob ntawm qhov kev pabcuam ntawd. Raws li lub sij hawm dhau mus thiab code accumulates, hloov cov neeg muag khoom ua
76
- nce untenable. Txais tos rau lub ntiaj teb kev lom zem ntawm tus neeg muag khoom xauv-hauv!
77
-
78
- Mobiletto tau tsim los daws qhov teeb meem no. Los ntawm coding koj app rau mobiletto's API, koj tuaj yeem yooj yim
79
- hloov chaw khaws cia thiab paub tias koj lub app cov txheej txheem cia yuav coj zoo ib yam.
80
-
81
- ### Kev sim dav dav
82
- Txhua tus tsav tsheb raug sim rau tus cwj pwm zoo ib yam nrog 60+ kev xeem rau txhua tus tsav tsheb.
83
- Peb sim txhua tus tsav tsheb nrog txhua qhov sib xyaw ua ke ntawm:
84
- * Encryption: ob qho tib si qhib thiab ua tsis taus
85
- * Redis cache: ob qho tib si qhib thiab ua tsis taus
86
-
87
- Txoj hauv kev no ua rau peb muaj kev thaj yeeb nyab xeeb uas mobiletto yuav coj zoo ib yam tsis hais tus tsav tsheb twg koj siv,
88
- thiab tsis hais seb koj puas qhib caching thiab / lossis encryption.
89
-
90
- ### Kev them nyiaj yug tsav tsheb
91
- Tam sim no Mobiletto cia tsav tsheb:
92
- * `s3` : Amazon S3
93
- * `b2` : Backblaze B2
94
- * `local` : local filesystem
95
-
96
- * Kev koom tes los txhawb ntau cov chaw muab huab cia tau txais tos heev!*
97
-
98
- ## mobiletto-cli
99
- Mobiletto yog npaj los siv los ua ib lub tsev qiv ntawv los ntawm lwm yam JavaScript code.
100
-
101
- Txhawm rau ua haujlwm nrog mobiletto ntawm kab hais kom ua, siv [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)
102
-
103
- ## Source
104
- * [mobiletto ntawm GitHub](https://github.com/cobbzilla/mobiletto)
105
- * [mobiletto on npm](https://www.npmjs.com/package/mobiletto)
106
-
107
- ## Kev them nyiaj yug thiab nyiaj txiag
108
- Kuv tab tom sim ua tus kws tshaj lij qhib qhov software tsim tawm. Kuv tau ua haujlwm hauv
109
- kev lag luam software tau ntau xyoo, kuv tau pib cov tuam txhab ua tiav thiab muag rau cov tuam txhab pej xeem.
110
- Tsis ntev los no kuv poob kuv txoj haujlwm, thiab kuv tsis muaj lwm txoj haujlwm ua haujlwm
111
-
112
- Yog li kuv yuav sim sau cov software pab tau thiab saib seb qhov ntawd ua haujlwm
113
-
114
- Yog tias koj txaus siab siv cov software no, kuv yuav ua tsaug ntau rau txawm tias cov
115
- tsawg tshaj plaws [kev pab nyiaj hli ntawm Patreon](https://www.patreon.com/cobbzilla)
116
-
117
- * Ua tsaug!*
118
-
119
- ## Kev teeb tsa
120
- Nruab siv `npm` lossis `yarn` . Tej zaum koj yuav xav tau `lite` version uas tsis suav nrog tag nrho cov
121
- txhais README cov ntaub ntawv:
122
-
123
- npm install mobiletto-lite
124
- yarn add mobiletto-lite
125
-
126
- Yog tias koj xav tau README cov ntaub ntawv hauv txhua hom lus, nruab tag nrho version:
127
-
128
- npm install mobiletto
129
- yarn add mobiletto
130
-
131
- ## Quick Start
132
- Piv txwv luv luv siv mobiletto `s3` tsav tsheb.
133
-
134
- Cov cai no yuav khiav zoo ib yam yog tias tus tsav tsheb yog `b2` lossis `local` .
135
-
136
- const storage = require('mobiletto')
137
- const bucket = await storage.connect('s3', aws_key, aws_secret, {bucket: 'bk'})
138
-
139
- // list objects: returns array of metadata objects
140
- const listing = await bucket.list()
141
- const dirList = await bucket.list('some/dir/')
142
- const everything = await bucket.list('', {recursive: true})
143
-
144
- // write an entire file
145
- let bytesWritten = await bucket.writeFile('some/path', someBufferOfData)
146
-
147
- // write a file from a stream/generator
148
- bytesWritten = await bucket.write('some/path', streamOrGenerator)
149
-
150
- // read an entire file
151
- // returns null if an exception would otherwise be thrown
152
- const bufferOrNull = await bucket.safeReadFile('some/path')
153
-
154
- // stream-read a file, passing data to callback
155
- const bytesRead = await bucket.read('some/path', (chunk) => { ...do something with chunk... } )
156
-
157
- // remove a file, returns the path removed
158
- let removed = await bucket.remove('some/path') // removed is a string
159
-
160
- // remove a directory, returns array of paths removed
161
- removed = await bucket.remove('some/directory', {recursive: true}) // removed is now an array!
162
-
163
- ----
164
- ## Kev siv yooj yim
165
- Ib qho piv txwv ntau dua, qhia txog feem ntau ntawm cov yam ntxwv muaj:
166
-
167
- const { mobiletto } = require('mobiletto')
168
-
169
- // General usage
170
- const api = await mobiletto(driverName, key, secret, opts)
171
-
172
- // To use 'local' driver:
173
- // * key: base directory
174
- // * secret: ignored, can be null
175
- // * opts object:
176
- // * readOnly: optional, never change anything on the filesystem; default is false
177
- // * fileMode: optional, permissions used when creating new files, default is 0600. can be string or integer
178
- // * dirMode: optional, permissions used when creating new directories, default is 0700. can be string or integer
179
- const local = await mobiletto('local', '/home/ubuntu/tmp', null, {fileMode: 0o0600, dirMode: '0700'})
180
-
181
- // To use 's3' driver:
182
- // * key: AWS Access Key ID
183
- // * secret: AWS Secret Key
184
- // * opts object:
185
- // * readOnly: optional, never change anything on the bucket; default is false
186
- // * bucket: required, name of the S3 bucket
187
- // * region: optional, the AWS region to communicate with, default is us-east-1
188
- // * prefix: optional, all read/writes within the S3 bucket will be under this prefix
189
- // * delimiter: optional, directory delimiter, default is '/' (note: always '/' when encryption is enabled)
190
- const s3 = await mobiletto('s3', aws_key, aws_secret, {bucket: 'bk', region: 'us-east-1'})
191
-
192
- // To use 'b2' driver:
193
- // * key: Backblaze Key ID
194
- // * secret: Backblaze Application Key
195
- // * opts object:
196
- // * readOnly: optional, never change anything on the bucket; default is false
197
- // * bucket: required, the ID (**not the name**) of the B2 bucket
198
- // * prefix: optional, all read/writes within the B2 bucket will be under this prefix
199
- // * delimiter: optional, directory delimiter, default is '/' (note: always '/' when encryption is enabled)
200
- // * partSize: optional, large files will be split into chunks of this size when uploading
201
- const b3 = await mobiletto('b2', b2_key_id, b2_app_key, {bucket: 'bk', partSize: 10000000})
202
-
203
- // List files
204
- api.list() // --> returns an array of metadata objects
205
-
206
- // List files recursively
207
- api.list({ recursive: true })
208
-
209
- // List files in a directory
210
- const path = 'some/path'
211
- api.list(path)
212
- api.list(path, { recursive: true }) // also supports recursive flag
213
-
214
- // Visit files in a directory -- visitor function must be async
215
- api.list(path, { visitor: myAsyncFunc })
216
- api.list(path, { visitor: myAsyncFunc, recursive: true })
217
-
218
- // The `list` method throws MobilettoNotFoundError if the path does not exist
219
- // When you call `safeList` on a non-existent path, it returns an empty array
220
- api.safeList('/path/that/does/not/exist') // returns []
221
-
222
- // Read metadata for a file
223
- api.metadata(path) // returns metadata object
224
-
225
- // The `metadata` method throws MobilettoNotFoundError if the path does not exist
226
- // When you call `safeMetadata` on a non-existent path, it returns null
227
- api.safeMetadata('/tmp/does_not_exist') // returns null
228
-
229
- // Read a file
230
- // Provide a callback that writes the data someplace
231
- const callback = (chunk) => { ... write chunk somewhere ... }
232
- api.read(path, callback) // returns count of bytes read
233
-
234
- // Read an entire file at once
235
- const data = await api.readFile(path) // returns a byte Buffer of the file contents
236
-
237
- // Read an entire file at once
238
- // returns null if an exception would otherwise be thrown
239
- const bufferOrNull = await bucket.safeReadFile('some/path')
240
-
241
- // Write a file
242
- // Provide a generator function that yields chunks of data
243
- const generator = function* () {
244
- while ( ... more-data-to-return ... ) {
245
- data = ... load-data ...
246
- yield data
247
- }
248
- }
249
- local.api(path, generator) // returns count of bytes written
250
-
251
- // Write an entire file at once (convenience method)
252
- await api.writeFile(path, bufferOrString) // returns count of bytes written
253
-
254
- // Delete a file
255
- // Quiet param is optional (default false), when set errors will not be thrown if the path does not exist
256
- // Always returns a value or throws an error.
257
- // Return value may be a single string of the file removed, or an array of all files removed (driver-dependent)
258
- const quiet = true
259
- api.remove(path, {quiet}) // returns single path removed
260
-
261
- // Recursively delete a directory and do it quietly (do not report errors)
262
- const recursive = true
263
- const quiet = true
264
- api.remove(path, {recursive, quiet}) // returns array of paths removed
265
-
266
- ## Metadata
267
- Cov lus txib `metadata` rov qab metadata txog ib qho kev nkag mus rau hauv ib qho chaw.
268
- Ib yam li ntawd, tus nqi xa rov qab los ntawm `list` daim ntawv' hais kom ua yog ib qho ntawm cov khoom metadata.
269
-
270
- Cov khoom metadata zoo li no:
271
-
272
- {
273
- "name": "fully/qualified/path/to/file",
274
- "type": "entry-type",
275
- "size": size-in-bytes,
276
- "ctime": creation-time-epoch-millis,
277
- "mtime": modification-time-epoch-millis
278
- }
279
-
280
- Cov `type` cuab yeej tuaj yeem yog `file` , `dir` , `link` , lossis `special` .
281
-
282
- Nyob ntawm seb hom tsav tsheb, `list` hais kom ua yuav tsis rov qab txhua qhov chaw. Cov `name` thiab `type` cov khoom
283
- yuav tsum muaj nyob. Cov lus txib `metadata` tom ntej yuav rov qab tag nrho cov khoom muaj.
284
-
285
- ## Hloov ntshuam style
286
- Ntshuam lub module tag nrho-scoped thiab siv `connect` muaj nuj nqi:
287
-
288
- const storage = require('mobiletto')
289
- const opts = {bucket: 'bk', region: 'us-east-1'}
290
- const s3 = await storage.connect('s3', aws_key, aws_secret, opts)
291
- const objectData = await s3.readFile('some/path')
292
-
293
- ## Caching
294
- Mobiletto ua haujlwm zoo tshaj plaws nrog <a href="https://redis.io">redis</a> cache.
295
-
296
- Mobiletto yuav sim txuas mus rau qhov piv txwv redis ntawm 127.0.0.1:6379
297
-
298
- Koj tuaj yeem override ib qho ntawm cov no:
299
- * Teem lub `MOBILETTO_REDIS_HOST` env var, mobiletto txuas ntawm no es tsis txhob localhost
300
- * Teem lub `MOBILETTO_REDIS_PORT` env var, qhov chaw nres nkoj no yuav raug siv
301
-
302
- Mobiletto yuav khaws tag nrho nws cov yuam sij redis nrog lub `_mobiletto__` . Koj tuaj yeem hloov qhov no
303
- los ntawm kev teeb tsa `MOBILETTO_REDIS_PREFIX` env var.
304
-
305
- Koj tuaj yeem teeb tsa ib qho kev sib txuas caching nrog `opts.redisConfig` khoom:
306
-
307
- const redisConfig = {
308
- enabled: true, // optional, default is true. if false other props are ignored
309
- host: '127.0.0.1',
310
- port: 6379,
311
- prefix: '_mobiletto__'
312
- }
313
- const opts = { redisConfig, bucket: 'bk', region: 'us-east-1' }
314
- const s3 = await storage.connect('s3', aws_key, aws_secret, opts)
315
-
316
- ### Tsis xav redis caching?
317
- Txhawm rau lov tes taw: hla `enabled: false` hauv koj qhov khoom `opts.redisConfig` thaum koj tsim koj qhov kev sib txuas.
318
-
319
- Raws li tau tham hauv qab no, kev tsis ua haujlwm caching yuav muaj kev cuam tshuam tsis zoo rau kev ua haujlwm thiab ua rau muaj kev thov ntau dua
320
- khaws cia uas koj xav tau tiag tiag.
321
-
322
- ### Caching kev taw qhia
323
- **Encrypted cia **: nyeem / sau ntawv encrypted cia tsuas yog me ntsis qeeb dua li qub,
324
- tab sis navigating ncig cov npe (uas qee yam ua) yog qhov kim heev. Siv lub redis cache
325
- yuav ua rau koj muaj kev txhawb nqa tseem ceeb.
326
-
327
- Lub neej ntawd cache muaj kev nyab xeeb, tab sis tsis ua haujlwm zoo yog tias koj muaj ntau qhov kev sau / tshem tawm haujlwm.
328
- Ib qho kev sau lossis tshem tawm kev ua haujlwm tsis raug cai tag nrho cov cache, kom ntseeg tau tias cov ntawv nyeem tom ntej yuav pom qhov
329
- kev hloov tshiab kawg.
330
-
331
- ### CLI cov cuab yeej
332
- Yog tias koj siv CLI cov cuab yeej xws li [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
333
- koj yuav xav tau lub redis cache enabled, raws li nws kav hla invocations ntawm `mo` hais kom ua.
334
-
335
- ## Daim iav
336
-
337
- // Copy a local filesystem mobiletto to S3
338
- s3.mirror(local)
339
-
340
- // Mirror a local subdirectory from one mobiletto to an S3 mobiletto, with it's own subdirectory
341
- local.mirror(s3, 'some/local-folder', 'some/s3-folder')
342
-
343
- Cov lus txib `mirror` ua ib daim ntawv luam ib zaug ntawm tag nrho cov ntaub ntawv los ntawm ib qho mobiletto mus rau lwm qhov.
344
- Nws tsis khiav ib qho txheej txheem los tswj daim iav hla lub sijhawm. Khiav qhov `mirror` hais kom ua dua
345
- synchronize tej ntaub ntawv uas ploj lawm.
346
-
347
- Tus nqi rov qab los ntawm `mirror` yog ib yam khoom yooj yim nrog cov txee rau pes tsawg cov ntaub ntawv tau ua tiav
348
- mirrored thiab pes tsawg cov ntaub ntawv muaj qhov yuam kev:
349
-
350
- {
351
- success: count-of-files-mirrored,
352
- errors: count-of-files-with-errors
353
- }
354
-
355
- CEEB TOOM: Mirroring loj cov ntaub ntawv teev yuav siv sij hawm heev thiab bandwidth-intensive
356
-
357
- Nrog rau `mirror` hu semantics nws tuaj yeem qee zaum tsis meej pem kom nkag siab tias leej twg yog tus
358
- nyeem ntawv thiab leej twg yog tus sau. Xav txog nws zoo li cov lus qhia: "sab laug-tes mobiletto"
359
- yog qhov uas tau muab rau (mirrored cov ntaub ntawv sau), thiab "sab tes mobiletto" (the
360
- kev sib cav rau `mirror` txoj kev) yog tus nqi raug muab (cov ntaub ntawv iav tau nyeem).
361
-
362
- ## Transparent encryption
363
- Pab kom pob tshab neeg-sab encryption:
364
-
365
- // Pass encryption parameters
366
- const encryption = {
367
- // key is required, must be >= 16 chars
368
- key: randomstring.generate(128),
369
-
370
- // optional, the default is to derive IV from key
371
- // when set, IV must be >= 16 chars
372
- iv: randomstring.generate(128),
373
-
374
- // optional, the default is aes-256-cbc
375
- algo: 'aes-256-cbc'
376
- }
377
- const api = await mobiletto(driverName, key, secret, opts, encryption)
378
-
379
- // Subsequent write operations will encrypt data (client side) when writing
380
- // Subsequent read operations will decrypt data (client side) when reading
381
-
382
- Yuav ua li cas? Ib qho "directory entry" (dirent) directory (encrypted) track what files are in that
383
- directory (aka lub dirent directory).
384
- * Cov lus txib `list` nyeem cov ntaub ntawv sau npe nkag, decrypts txhua txoj hauv kev teev tseg; ces rov metadata rau txhua cov ntaub ntawv
385
- * `list` cov lus txib tsis muaj txiaj ntsig, tshwj xeeb tshaj yog rau cov npe nrog cov ntaub ntawv ntau
386
- * Cov lus txib `write` sau' sau cov ntaub ntawv sib txawv hauv txhua tus niam txiv phau ntawv qhia, recursively; ces sau cov ntaub ntawv
387
- * `write` cov lus txib yuav ua rau O(N) sau, nrog N = qhov tob hauv cov npe hierarchy
388
- * Cov lus txib `remove` tshem tawm" tshem tawm cov ntaub ntawv sib thooj, thiab nws niam nws txiv yog khoob, rov ua dua; ces tshem tawm cov ntaub ntawv
389
- * Tsis-recursive `remove` cov lus txib yuav ua rau O (N) nyeem thiab muaj peev xwm ntau li tshem tawm, nrog N = qhov tob hauv cov npe hierarchy
390
- * Recursive `remove` cov lus txib ntawm cov ntaub ntawv loj thiab sib sib zog nqus tuaj yeem kim
391
-
392
- Nco ntsoov tias txawm tias tus neeg siv-sab encryption tau qhib, tus yeeb ncuab nrog kev pom tag nrho rau hauv koj lub server-sab encrypted
393
- cia, txawm tias tsis muaj tus yuam sij, tseem tuaj yeem pom tag nrho cov npe ntawm cov npe thiab pes tsawg cov ntaub ntawv nyob hauv txhua, thiab nrog
394
- qee qhov kev siv zog, nrhiav qee qhov lossis tag nrho cov qauv ntawm cov npe hierarchy.
395
- * Ceeb toom: Siv cov qauv tiaj tus kom muaj kev ruaj ntseg zoo dua.*
396
- Tus yeeb ncuab yuav tsis paub cov npe ntawm cov npe / cov ntaub ntawv tshwj tsis yog lawv kuj paub koj qhov encryption
397
- tus yuam sij los yog muaj lwm yam ua tau zoo tawg qhov encryption. Tag nrho cov bets yog tawm thaum ntawd!
398
-
399
- ### Kev ua tau zoo thiab caching
400
- Kev ua haujlwm ntawm encrypted cia yuav qeeb. Recursive cov npe thiab tshem tawm tuaj yeem qeeb heev.
401
- Caching ntawm redis pab tau zoo heev, tab sis nco ntsoov tias lub cache yog flushed thaum sau lossis tshem tawm.
402
-
403
- ## Kev hloov pauv hloov pauv
404
- Tsim ib lub mobiletto nrog koj tus yuam sij tshiab, tom qab ntawd tsom iav cov ntaub ntawv qub rau hauv nws:
405
-
406
- const storage = require('mobiletto')
407
-
408
- const oldEncryption = { key: .... }
409
- const oldStorage = await storage.connect('s3', aws_key, aws_secret, {bucket: 'bk', region: 'us-east-1'}, oldEncryption)
410
-
411
- const newEncryption = { key: .... }
412
- const newStorage = await storage.connect('s3', aws_key, aws_secret, {bucket: 'zz', region: 'us-east-1'}, newEncryption)
413
-
414
- newStorage.mirror(oldStorage) // if oldStorage is very large, this may take a looooooong time...
415
-
416
- ## Tus tsav tsheb interface
417
- Tus neeg tsav tsheb yog cov ntaub ntawv JS uas xa tawm 'storageClient' muaj nuj nqi nrog qhov kos npe no:
418
-
419
- function storageClient (key, secret, opts)
420
-
421
- * `key` : ib txoj hlua, koj tus yuam sij API (rau `local` tsav tsheb no yog lub hauv paus phau ntawv qhia)
422
- * `secret` : txoj hlua, koj qhov API zais cia (tuaj yeem raug tshem tawm rau `local` tsav tsheb)
423
- * `opts` : ib qho khoom, cov khoom yog ib tus tsav tsheb:
424
- * Rau `local` hauv zos', `fileMode` thiab `dirMode` cov khoom txiav txim siab li cas cov ntaub ntawv tsim tshiab thiab cov npe raug tsim
425
- * Rau `s3` , yuav tsum muaj `bucket` khoom. Cov khoom xaiv tau yog:
426
- * `region`: the S3 region, default is us-east-1
427
- * `prefix`: a prefix to prepend to all S3 paths, default is the empty string
428
- * `delimiter`: the directory delimiter, default is '/'
429
-
430
- Cov khoom uas lub storageClient muaj nuj nqi xa rov qab yuav tsum txhais cov haujlwm no:
431
-
432
- // Test the driver before using, ensure proper configuration
433
- async testConfig ()
434
-
435
- // List files in path (or from base-directory)
436
- // If recursive is true, list recursively
437
- // If visitor is defined, it will be an async function. await the visitor function on each file found
438
- // Otherwise, perform the listing and return an array of objects
439
- async list (path, recursive = false, visitor = null) // path may be omitted
440
-
441
- // Read metadata for a path
442
- async metadata (path)
443
-
444
- // Read a file
445
- // callback receives a chunk of data. endCallback is called at end-of-stream
446
- async read (path, callback, endCallback = null)
447
-
448
- // Write a file
449
- // driver must be able to handle a generator or a stream
450
- async write (path, generatorOrReadableStream)
451
-
452
- // Remove a file, or recursively delete a directory
453
- // returns a string of a single path removed, or an array of multiple paths removed
454
- async remove (path, recursive = false, quiet = false)
455
-
456
- ## Kev sau npe
457
- Mobiletto siv lub [winston](https://www.npmjs.com/package/winston) kaw lub tsev qiv ntawv.
458
-
459
- Logs **yuav ** muaj cov ntaub ntawv txoj hauv kev thiab cov lus yuam kev, tab sis yuav ** yeej tsis ** muaj cov yuam sij, zais cia,
460
- los yog lwm yam kev sib txuas lus configuration.
461
-
462
- ### Log theem
463
- Siv `MOBILETTO_LOG_LEVEL` ib puag ncig hloov pauv los teeb tsa theem cav, siv ib qho
464
- ntawm cov qib `npm` txhais hauv [https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels)
465
-
466
- Cov theem pib yog `error` . Qhov feem ntau verbose theem yog `silly` , txawm hais tias tam sim no mobiletto
467
- tsis teev nyob rau theem hauv qab `debug`
468
-
469
- MOBILETTO_LOG_LEVEL=silly # maximum logs!
470
-
471
- ### Log file
472
- Los ntawm lub neej ntawd, tus logger sau rau lub console. Txhawm rau xa cov cav mus rau cov ntaub ntawv, teeb tsa `MOBILETTO_LOG_FILE`
473
- ib puag ncig hloov pauv. Thaum nkag mus rau cov ntaub ntawv, cov cav yuav tsis raug sau rau lub console lawm.
474
-
475
- MOBILETTO_LOG_FILE=/var/my_mobiletto_log
476
-
477
- Txhawm rau kaw qhov kev kaw tseg:
478
-
479
- MOBILETTO_LOG_FILE=/dev/null
480
-
481
- </pre>