mobiletto 1.2.0 → 2.0.0

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 (127) 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 -10
  123. package/test/api.spec.js +0 -512
  124. package/test/crypt.spec.js +0 -67
  125. package/util/crypt.js +0 -80
  126. package/util/logger.js +0 -27
  127. package/util/redis.js +0 -233
package/docs/ht/README.md DELETED
@@ -1,481 +0,0 @@
1
- Mobiletto
2
- =========
3
-
4
- Mobiletto se yon kouch abstraksyon depo JavaScript, ak si ou vle chifreman transparan bò kliyan.
5
-
6
- # Kontni
7
- * [Poukisa Mobiletto?](#Poukisa-Mobiletto?)
8
- * [Kòmanse rapid](#Kòmanse rapid)
9
- * [Mobiletto CLI](#mobiletto-cli)
10
- * [Sous](#Sous)
11
- * [Enstalasyon](#Enstalasyon)
12
- * [Sipò ak Finansman](#Sipò-ak-Finansman)
13
- * [Itilizasyon debaz](#Itilizasyon debaz)
14
- * [Metadone](#Metadone)
15
- * [Altènatif enpòte style](#Altènatif-enpòte-style)
16
- * [Caching](#Caching)
17
- * [Mirroring](#Mirroring)
18
- * [Transparan chifreman](#Transparent-chiffrement)
19
- * [Wotasyon kle](#Kle-wotasyon)
20
- * [Koòdone chofè](#Driver-koòdone)
21
- * [Logging](#Logging)
22
-
23
- # Li sa nan yon lòt lang
24
- Dokiman README.md sa a te tradui, atravè [hokeylization](https://github.com/cobbzilla/hokeylization), nan
25
- **[chak lang Google Translate sipòte](https://cloud.google.com/translate/docs/languages)!**
26
-
27
- Mwen sèten li pa pafè, men mwen espere ke li pi bon pase anyen!
28
-
29
- [🇸🇦 Arabe](../ar/README.md)
30
- [🇧🇩 Bengali](../bn/README.md)
31
- [🇩🇪 Alman](../de/README.md)
32
- [🇺🇸 Angle](../en/README.md)
33
- [🇪🇸 Panyòl](../es/README.md)
34
- [🇫🇷 Franse](../fr/README.md)
35
- [🇹🇩 Hausa](../ha/README.md)
36
- [🇮🇳 Hindi](../hi/README.md)
37
- [🇮🇩 Endonezyen](../id/README.md)
38
- [🇮🇹 Italyen](../it/README.md)
39
- [🇯🇵 Japonè](../ja/README.md)
40
- [🇰🇷 Koreyen](../ko/README.md)
41
- [🇮🇳 Marathi](../mr/README.md)
42
- [🇵🇱 Polonè](../pl/README.md)
43
- [🇧🇷 Pòtigè](../pt/README.md)
44
- [🇷🇺 Ris](../ru/README.md)
45
- [🇰🇪 Swahili](../sw/README.md)
46
- [🇵🇭 Tagalog](../tl/README.md)
47
- [🇹🇷 Tik](../tr/README.md)
48
- [🇵🇰 Oudou](../ur/README.md)
49
- [🇻🇳 Vyetnamyen](../vi/README.md)
50
- [🇨🇳 Chinwa](../zh/README.md)
51
-
52
-
53
- **[📚 ... Tout Lang ...](../README.md)**
54
- ----
55
-
56
- ### Èske gen yon pwoblèm ak tradiksyon README sa a?
57
- Tradiksyon patikilye sa a orijinal [README](https://github.com/cobbzilla/mobiletto/blob/master/README.md)
58
- ka gen defo -- *koreksyon yo trè akeyi!* Tanpri voye yon [pull demand sou GitHub](https://github.com/cobbzilla/mobiletto/pulls),
59
- oswa si w pa konfòtab pou w fè sa, [louvri yon pwoblèm](https://github.com/cobbzilla/mobiletto/issues)
60
-
61
- Lè ou kreye yon nouvo pwoblèm GitHub sou yon tradiksyon, tanpri fè:
62
- * enkli URL paj la (kopi/kole nan ba adrès navigatè a)
63
- * enkli tèks egzak ki mal (kopi/kole nan navigatè a)
64
- * Tanpri dekri sa ki mal -- èske tradiksyon an pa kòrèk? se fòma a kase yon jan kanmenm?
65
- * Tanpri ofri yon sijesyon sou yon pi bon tradiksyon, oswa ki jan tèks la ta dwe byen fòma
66
- * **Mèsi!**
67
-
68
- ## Poukisa Mobiletto?
69
-
70
- ### Orevwa machann lock-in!
71
- Divès kalite founisè depo nwaj yo gen API enkonpatib. Menm moun ki fè efò pou "S3 konpatibilite"
72
- gen konpòtman idiosinkratik.
73
-
74
- Lè w chwazi yon machann depo patikilye pou aplikasyon w lan, si w kode dirèkteman nan API yo, aplikasyon w lan
75
- se kounye a depann sou sèvis sa a. Kòm tan ap pase ak kòd akimile, chanje fournisseurs vin
76
- de pli zan pli insoutenab. Byenveni nan mond lan amizan nan fèmen vandè!
77
-
78
- Mobiletto te fèt pou rezoud pwoblèm sa a. Lè w kode aplikasyon w lan nan API mobiletto a, ou ka fasilman
79
- chanje founisè depo epi konnen ke kouch depo app ou a ap konpòte menm jan an.
80
-
81
- ### Tès vaste
82
- Tout chofè yo teste pou konpòtman ki idantik ak plis pase 60 tès pou chak chofè.
83
- Nou teste tout chofè ak tout konbinezon de:
84
- * Chifre: tou de aktive ak enfim
85
- * Redis kachèt: tou de aktive ak enfim
86
-
87
- Apwòch sa a ban nou lapè-of-espri ke mobiletto pral konpòte menm jan kèlkeswa chofè ou itilize,
88
- ak kèlkeswa si ou pèmèt kachèt ak/oswa chifreman.
89
-
90
- ### Sipò chofè
91
- Chofè depo Mobiletto aktyèl yo:
92
- * `s3` : Amazon S3
93
- * `b2` : Backblaze B2
94
- * `local` : sistèm dosye lokal
95
-
96
- *Kontribisyon pou sipòte plis founisè depo nwaj yo trè akeyi!*
97
-
98
- ## mobiletto-cli
99
- Mobiletto fèt pou itilize kòm yon bibliyotèk pa lòt kòd JavaScript.
100
-
101
- Pou travay ak mobiletto nan liy lòd la, sèvi ak [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)
102
-
103
- ## Sous
104
- * [mobiletto sou GitHub](https://github.com/cobbzilla/mobiletto)
105
- * [mobiletto sou npm](https://www.npmjs.com/package/mobiletto)
106
-
107
- ## Sipò ak Finansman
108
- Mwen eseye vin yon pwofesyonèl devlopè lojisyèl sous louvri. Mwen te travay nan
109
- endistri a lojisyèl pou anpil ane, mwen te kòmanse konpayi siksè ak vann yo bay konpayi piblik yo.
110
- Dènyèman mwen pèdi travay mwen, e mwen pa vrèman gen okenn lòt travay ki aliye
111
-
112
- Se konsa, mwen pral eseye ekri lojisyèl itil epi wè si sa ap travay
113
-
114
- Si ou renmen itilize lojisyèl sa a, mwen ta trè rekonesan pou menm a
115
- pi piti [kontribisyon chak mwa atravè Patreon](https://www.patreon.com/cobbzilla)
116
-
117
- *Mèsi!*
118
-
119
- ## Enstalasyon
120
- Enstale lè l sèvi avèk `npm` oswa `yarn` . Ou pwobableman vle vèsyon an `lite` ki pa gen ladann tout
121
- dosye README tradui:
122
-
123
- npm install mobiletto-lite
124
- yarn add mobiletto-lite
125
-
126
- Si ou reyèlman vle dosye README yo nan tout lang, enstale vèsyon konplè a:
127
-
128
- npm install mobiletto
129
- yarn add mobiletto
130
-
131
- ## Kòmanse rapid
132
- Yon egzanp kout lè l sèvi avèk chofè mobiletto `s3` .
133
-
134
- Kòd sa a ta kouri menm si chofè a te `b2` oswa `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
- ## Itilizasyon debaz
165
- Yon egzanp pi plis vaste, ki montre pi fò nan karakteristik yo ofri:
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
- Kòmand `metadata` la retounen metadata sou yon sèl antre sistèm fichye.
268
- Menm jan an tou, valè retounen nan lòd `list` la se yon etalaj de objè metadata.
269
-
270
- Yon objè metadata sanble sa a:
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
- Pwopriyete `type` a kapab `file` , `dir` , `link` , oswa `special` .
281
-
282
- Tou depan de kalite chofè a, yon lòd `list` ka pa retounen tout jaden yo. Pwopriyete `name` ak `type`
283
- ta dwe toujou prezan. Yon lòd `metadata` ki vin apre ap retounen tout pwopriyete ki disponib yo.
284
-
285
- ## Altène style enpòte
286
- Enpòte modil totalman an epi sèvi ak fonksyon `connect` :
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
- ## Cache
294
- Mobiletto travay pi byen ak yon kachèt <a href="https://redis.io">redis</a> .
295
-
296
- Mobiletto pral eseye konekte ak yon egzanp redis sou 127.0.0.1:6379
297
-
298
- Ou ka depase youn nan sa yo:
299
- * Mete `MOBILETTO_REDIS_HOST` env var, mobiletto konekte isit la olye de localhost
300
- * Mete `MOBILETTO_REDIS_PORT` env var, pò sa a pral itilize
301
-
302
- Mobiletto pral estoke tout kle redis li yo ak prefiks `_mobiletto__` . Ou ka chanje sa
303
- pa mete `MOBILETTO_REDIS_PREFIX` env var.
304
-
305
- Ou kapab tou mete kach pou chak koneksyon ak objè `opts.redisConfig` :
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
- ### Ou pa vle redis kachèt?
317
- Pou enfim: pase `enabled: false` nan objè `opts.redisConfig` ou lè ou etabli koneksyon ou.
318
-
319
- Jan yo diskite pi ba a, enfimite kachèt pral gen yon efè negatif sou pèfòmans ak antrene plis demann
320
- nan depo ke ou reyèlman bezwen.
321
-
322
- ### Kache konsèy
323
- **Depo kode**: lekti/ekri depo kode se sèlman yon ti kras pi dousman pase nòmal,
324
- men navige nan repèrtwar (ki kèk bagay fè) se jistis chè. Sèvi ak yon kachèt redis
325
- pral ba ou yon ogmantasyon siyifikatif pèfòmans.
326
-
327
- Kachèt default la an sekirite, men li pa fè byen si ou gen anpil operasyon ekri/retire.
328
- Nenpòt operasyon ekri oswa retire invalid kachèt la tout antye, asire lekti ki vin apre yo pral wè
329
- dènye chanjman.
330
-
331
- ### CLI zouti
332
- Si w ap itilize yon zouti CLI tankou [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
333
- ou pral definitivman vle redis kachèt la aktive, kòm li dire atravè envokasyon nan lòd `mo` .
334
-
335
- ## Mirroring
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
- `mirror` la fè yon kopi yon sèl fwa nan tout dosye soti nan yon mobiltto nan yon lòt.
344
- Li pa kouri okenn pwosesis pou kenbe glas la sou tan. Kouri kòmand `mirror` ankò
345
- pou senkronize nenpòt ki dosye ki manke.
346
-
347
- Valè retounen nan `mirror` se yon objè senp ak kontè pou konbyen dosye yo te reyisi
348
- reflete ak konbyen dosye ki te gen erè:
349
-
350
- {
351
- success: count-of-files-mirrored,
352
- errors: count-of-files-with-errors
353
- }
354
-
355
- AVÈTISMAN: Reflete seri gwo done yo ka pran anpil tan ak Pleasant-entansif
356
-
357
- Avèk semantik apèl `mirror` li pafwa kapab konfizyon pou w konprann kiyès ki la
358
- lektè ak ki moun ki ekriven an. Imajine li tankou yon deklarasyon devwa: "mobiletto nan men gòch"
359
- se bagay yo te plase nan (replike done ekri), ak "mobiletto adwat" (la
360
- agiman nan metòd `mirror` ) se valè yo te bay (done yo miroir li).
361
-
362
- ## Chifre transparan
363
- Pèmèt transparan chifreman bò kliyan:
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
- Sak ap pase? Yon separe "antre anyè" (direksyon) anyè (chiffre) swiv ki fichye yo nan sa
383
- anyè (aka anyè dirent).
384
- * `list` la li dosye yo antre anyè, dekripte chak chemen ki nan lis la; Lè sa a, retounen metadata pou chak dosye
385
- * `list` yo pi efikas, espesyalman pou anyè ki gen yon gwo kantite fichye
386
- * `write` ekri fichye dirent nan anyè diret chak paran, yon fason rekursif; Lè sa a, ekri fichye a
387
- * `write` yo pral fè O(N) ekri, ak N = pwofondè nan yerachi anyè a.
388
- * `remove` retire fichye dirent ki koresponn lan, ak paran li si li vid, yon fason repetitif; Lè sa a, retire dosye a
389
- * `remove` ki pa rekursif yo pral fè lekti O(N) ak potansyèlman anpil efase, ak N = pwofondè nan yerachi anyè a.
390
- * `remove` repetitif sou sistèm fichye gwo ak gwo twou san fon ka chè
391
-
392
- Remake byen ke menm avèk chifreman bò kliyan pèmèt, yon advèsè ki gen yon vizibilite konplè sou bò sèvè chiffres ou.
393
- depo, menm san kle a, ka toujou wè kantite total anyè ak konbyen fichye yo nan chak, ak
394
- kèk efò, dekouvri kèk oswa tout estrikti an jeneral nan yerachi anyè a.
395
- *Remak: Sèvi ak yon estrikti relativman plat pou pi bon sekirite.*
396
- Advèsè a pa ta konnen non anyè / fichye yo sof si yo te konnen tou chifreman ou
397
- kle oswa te gen otreman avèk siksè fann chifreman an. Lè sa a, tout parye yo koupe!
398
-
399
- ### Pèfòmans ak kachèt
400
- Operasyon sou depo chiffres kapab dousman. Lis rekursif ak retire ka trè dousman.
401
- Cache atravè redis ede anpil, men sonje ke kachèt la vide sou nenpòt ki ekri oswa retire.
402
-
403
- ## Wotasyon kle
404
- Kreye yon mobiletto ak nouvo kle ou a, epi reflete ansyen done yo nan li:
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
- ## Koòdone chofè
417
- Yon chofè se nenpòt fichye JS ki ekspòte yon fonksyon 'storageClient' ak siyati sa a:
418
-
419
- function storageClient (key, secret, opts)
420
-
421
- * `key` : yon kòd, kle API ou (pou chofè `local` sa a se anyè debaz la)
422
- * `secret` : yon kòd, sekrè API ou (yo ka omisyon pou chofè `local` )
423
- * `opts` : yon objè, pwopriyete yo se pou chak chofè:
424
- * Pou `local` , pwopriyete `fileMode` ak `dirMode` detèmine fason yo kreye nouvo fichye ak anyè.
425
- * Pou `s3` , pwopriyete a `bucket` obligatwa. Pwopriyete opsyonèl yo se:
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
- Objè ke fonksyon storageClient retounen dwe defini fonksyon sa yo:
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
- ## Enregistrement
457
- Mobiletto sèvi ak bibliyotèk ki anrejistre [winston](https://www.npmjs.com/package/winston).
458
-
459
- Jounal yo **ap** gen ladann chemen fichye yo ak mesaj erè, men yo p ap **pa janm** genyen kle, sekrè,
460
- oswa nenpòt lòt enfòmasyon konfigirasyon koneksyon.
461
-
462
- ### Log nivo
463
- Sèvi ak varyab anviwònman `MOBILETTO_LOG_LEVEL` pou mete nivo mòso a, lè l sèvi avèk youn
464
- nan nivo `npm` yo defini nan [https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels)
465
-
466
- Nivo default la se `error` . Nivo ki pi pwolib la se `silly` , byenke kounye a mobiletto
467
- pa konekte nan nivo anba a `debug`
468
-
469
- MOBILETTO_LOG_LEVEL=silly # maximum logs!
470
-
471
- ### Log dosye
472
- Pa default, logger la ekri nan konsole a. Pou voye mòso bwa nan yon fichye, mete `MOBILETTO_LOG_FILE`
473
- anviwònman varyab. Lè w ap antre nan yon dosye, mòso bwa yo p ap ekri sou konsole a ankò.
474
-
475
- MOBILETTO_LOG_FILE=/var/my_mobiletto_log
476
-
477
- Pou fèmen enregistrement:
478
-
479
- MOBILETTO_LOG_FILE=/dev/null
480
-
481
- </pre>