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
package/docs/tl/README.md DELETED
@@ -1,481 +0,0 @@
1
- Mobiletto
2
- =========
3
-
4
- Ang Mobiletto ay isang JavaScript storage abstraction layer, na may opsyonal na transparent na client-side encryption.
5
-
6
- # Nilalaman
7
- * [Bakit Mobiletto?](#Why-Mobiletto?)
8
- * [Quick start](#Quick-start)
9
- * [Mobiletto CLI](#mobiletto-cli)
10
- * [Source](#Source)
11
- * [Pag-install](#Pag-install)
12
- * [Suporta at Pagpopondo](#Support-and-Funding)
13
- * [Basic na paggamit](#Basic-usage)
14
- * [Metadata](#Metadata)
15
- * [Alternate import style](#Alternate-import-style)
16
- * [Caching](#Caching)
17
- * [Mirroring](#Mirroring)
18
- * [Transparent na pag-encrypt](#Transparent-encryption)
19
- * [Pag-ikot ng key](#Pag-ikot ng key)
20
- * [Driver interface](#Driver-interface)
21
- * [Logging](#Logging)
22
-
23
- # Basahin ito sa ibang wika
24
- Itong README.md na dokumento ay isinalin, sa pamamagitan ng [hokeylization](https://github.com/cobbzilla/hokeylization), sa
25
- **[bawat wikang sinusuportahan ng Google Translate](https://cloud.google.com/translate/docs/languages)!**
26
-
27
- Natitiyak kong hindi ito perpekto, ngunit umaasa ako na ito ay mas mahusay kaysa sa wala!
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
- [🇫🇷 French](../fr/README.md)
35
- [🇹🇩 Hausa](../ha/README.md)
36
- [🇮🇳 Hindi](../hi/README.md)
37
- [🇮🇩 Indonesian](../id/README.md)
38
- [🇮🇹 Italyano](../it/README.md)
39
- [🇯🇵 Japanese](../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
- [🇻🇳 Vietnamese](../vi/README.md)
50
- [🇨🇳 Chinese](../zh/README.md)
51
-
52
-
53
- **[📚 ... Lahat ng Wika ...](../README.md)**
54
- ----
55
-
56
- ### May problema ba sa pagsasaling ito ng README?
57
- Ang partikular na pagsasaling ito ng orihinal na [README](https://github.com/cobbzilla/mobiletto/blob/master/README.md)
58
- maaaring may depekto -- *ang mga pagwawasto ay malugod na tinatanggap!* Mangyaring magpadala ng [pull request sa GitHub](https://github.com/cobbzilla/mobiletto/pulls),
59
- o kung hindi ka komportableng gawin iyon, [magbukas ng isyu](https://github.com/cobbzilla/mobiletto/issues)
60
-
61
- Kapag gumawa ka ng bagong isyu sa GitHub tungkol sa isang pagsasalin, mangyaring gawin ang:
62
- * isama ang URL ng pahina (kopyahin/i-paste mula sa address bar ng browser)
63
- * isama ang eksaktong text na mali (kopyahin/i-paste mula sa browser)
64
- * mangyaring ilarawan kung ano ang mali -- mali ba ang pagsasalin? sira ba ang formatting kahit papaano?
65
- * mabait na mag-alok ng isang mungkahi ng isang mas mahusay na pagsasalin, o kung paano ang teksto ay dapat na maayos na na-format
66
- * **Salamat!**
67
-
68
- ## Bakit Mobiletto?
69
-
70
- ### Paalam vendor lock-in!
71
- Ang iba't ibang mga provider ng cloud storage ay may mga hindi tugmang API. Kahit na ang mga nagsusumikap para sa "S3 compatibility"
72
- may idiosyncratic na pag-uugali.
73
-
74
- Kapag pumili ka ng partikular na vendor ng storage para sa iyong app, kung direkta kang magko-code sa kanilang API, ang iyong app
75
- ay nakadepende na ngayon sa serbisyong iyon. Habang lumilipas ang panahon at naiipon ang code, nagiging nagbabago ang mga vendor
76
- lalong hindi matitiis. Maligayang pagdating sa masayang mundo ng vendor lock-in!
77
-
78
- Ang Mobiletto ay idinisenyo upang malutas ang problemang ito. Sa pamamagitan ng pag-coding sa iyong app sa mobiletto's API, madali mong magagawa
79
- baguhin ang mga provider ng storage at alamin na ang layer ng storage ng iyong app ay magiging magkapareho.
80
-
81
- ### Malawak na pagsubok
82
- Ang lahat ng mga driver ay sinubok para sa magkatulad na pag-uugali na may 60+ na pagsubok para sa bawat driver.
83
- Sinusubukan namin ang lahat ng mga driver sa bawat kumbinasyon ng:
84
- * Encryption: parehong pinagana at hindi pinagana
85
- * Redis cache: parehong pinagana at hindi pinagana
86
-
87
- Ang diskarte na ito ay nagbibigay sa amin ng kapayapaan ng isip na ang mobiletto ay magiging pareho ang kilos anuman ang ginagamit mong driver,
88
- at hindi alintana kung pinagana mo ang pag-cache at/o pag-encrypt.
89
-
90
- ### Suporta sa driver
91
- Kasalukuyang mga driver ng imbakan ng Mobiletto:
92
- * `s3` : Amazon S3
93
- * `b2` : Backblaze B2
94
- * `local` : lokal na filesystem
95
-
96
- *Ang mga kontribusyon upang suportahan ang higit pang mga provider ng cloud storage ay malugod na tinatanggap!*
97
-
98
- ## mobiletto-cli
99
- Ang Mobiletto ay inilaan na gamitin bilang isang library ng ibang JavaScript code.
100
-
101
- Upang gumana sa mobiletto sa command-line, gamitin ang [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)
102
-
103
- ## Pinagmulan
104
- * [mobiletto sa GitHub](https://github.com/cobbzilla/mobiletto)
105
- * [mobiletto sa npm](https://www.npmjs.com/package/mobiletto)
106
-
107
- ## Suporta at Pagpopondo
108
- Sinusubukan kong maging isang propesyonal na open source software developer. Ako ay nagtatrabaho sa
109
- sa industriya ng software sa loob ng maraming taon, sinimulan ko ang mga matagumpay na kumpanya at ibinenta ang mga ito sa mga pampublikong kumpanya.
110
- Kamakailan ay nawalan ako ng trabaho, at wala talaga akong ibang trabahong naka-line up
111
-
112
- Kaya't susubukan kong magsulat ng kapaki-pakinabang na software at tingnan kung gumagana iyon
113
-
114
- Kung masiyahan ka sa paggamit ng software na ito, ako ay lubos na nagpapasalamat para sa kahit na ang
115
- pinakamaliit [buwanang kontribusyon sa pamamagitan ng Patreon](https://www.patreon.com/cobbzilla)
116
-
117
- *Salamat!*
118
-
119
- ## Pag-install
120
- I-install gamit `npm` o `yarn` . Malamang na gusto mo ang `lite` na bersyon na hindi kasama ang lahat ng
121
- isinalin na README file:
122
-
123
- npm install mobiletto-lite
124
- yarn add mobiletto-lite
125
-
126
- Kung talagang gusto mo ang README file sa bawat wika, i-install ang buong bersyon:
127
-
128
- npm install mobiletto
129
- yarn add mobiletto
130
-
131
- ## Mabilis na Pagsisimula
132
- Isang maikling halimbawa gamit ang mobiletto `s3` driver.
133
-
134
- Ang code na ito ay tatakbo nang pareho kung ang driver ay `b2` o `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
- ## Pangunahing paggamit
165
- Isang mas malawak na halimbawa, na nagpapakita ng karamihan sa mga tampok na inaalok:
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
- Ang utos `metadata` ay nagbabalik ng metadata tungkol sa isang entry ng filesystem.
268
- Gayundin, ang return value mula sa command na `list` ay isang hanay ng mga metadata object.
269
-
270
- Ang isang metadata object ay ganito ang hitsura:
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
- Ang property na ` `type` ay maaaring `file` , `dir` , `link` , o `special` .
281
-
282
- Depende sa uri ng driver, maaaring hindi ibalik ng `list` command ang lahat ng field. Ang mga katangian ng `name` at `type`
283
- dapat laging naroroon. Ibabalik ng kasunod na command `metadata` ang lahat ng available na property.
284
-
285
- ## Kahaliling istilo ng pag-import
286
- I-import ang fully-scoped module at gamitin ang `connect` function:
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
- ## Pag-cache
294
- Pinakamahusay na gumagana ang Mobiletto sa isang <a href="https://redis.io">redis</a> cache.
295
-
296
- Susubukan ng Mobiletto na kumonekta sa isang redis instance sa 127.0.0.1:6379
297
-
298
- Maaari mong i-override ang alinman sa mga ito:
299
- * Itakda ang `MOBILETTO_REDIS_HOST` env var, mobiletto kumonekta dito sa halip na localhost
300
- * Itakda ang `MOBILETTO_REDIS_PORT` env var, ang port na ito ang gagamitin
301
-
302
- Iimbak ng Mobiletto ang lahat ng redis key nito na may prefix `_mobiletto__` . Maaari mong baguhin ito
303
- sa pamamagitan ng pagtatakda ng `MOBILETTO_REDIS_PREFIX` env var.
304
-
305
- Maaari ka ring magtakda ng per-connection caching gamit ang object na `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
- ### Ayaw ng redis caching?
317
- Upang i-disable: ipasa `enabled: false` sa iyong object `opts.redisConfig` kapag itinatag mo ang iyong koneksyon.
318
-
319
- Tulad ng tinalakay sa ibaba, ang hindi pagpapagana ng caching ay magkakaroon ng masamang epekto sa pagganap at magkakaroon ng higit pang mga kahilingan
320
- sa imbakan na talagang kailangan mo.
321
-
322
- ### Gabay sa pag-cache
323
- **Naka-encrypt na storage**: ang pagbabasa/pagsusulat ng naka-encrypt na storage ay mas mabagal lang ng kaunti kaysa sa karaniwan,
324
- ngunit ang pag-navigate sa mga direktoryo (na ginagawa ng ilang bagay) ay medyo mahal. Paggamit ng redis cache
325
- ay magbibigay sa iyo ng makabuluhang pagpapalakas ng pagganap.
326
-
327
- Ang default na cache ay ligtas, ngunit hindi gumaganap nang maayos kung mayroon kang maraming mga operasyon sa pagsulat/pag-alis.
328
- Ang anumang operasyon sa pagsulat o pag-alis ay nagpapawalang-bisa sa buong cache, na tinitiyak na makikita ng mga kasunod na pagbabasa ang
329
- pinakabagong pagbabago.
330
-
331
- ### CLI tool
332
- Kung gumagamit ka ng CLI tool tulad ng [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
333
- tiyak na gugustuhin mong paganahin ang redis cache, dahil tumatagal ito sa mga invocation ng utos na `mo` .
334
-
335
- ## Pagsasalamin
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
- Ang utos `mirror` ay nagsasagawa ng isang beses na kopya ng lahat ng mga file mula sa isang mobiletto patungo sa isa pa.
344
- Hindi ito nagpapatakbo ng anumang proseso upang mapanatili ang salamin sa paglipas ng panahon. Patakbuhin muli ang utos na `mirror`
345
- upang i-synchronize ang anumang nawawalang mga file.
346
-
347
- Ang return value mula sa `mirror` ay isang simpleng bagay na may mga counter para sa kung gaano karaming mga file ang matagumpay
348
- na-mirror at kung gaano karaming mga file ang may mga error:
349
-
350
- {
351
- success: count-of-files-mirrored,
352
- errors: count-of-files-with-errors
353
- }
354
-
355
- BABALA: Ang pag-mirror ng malalaking set ng data ay maaaring masyadong nakakaubos ng oras at bandwidth-intensive
356
-
357
- Sa `mirror` call semantics, minsan ay nakakalito kung sino ang
358
- mambabasa at sino ang manunulat. Isipin ito tulad ng isang pahayag ng pagtatalaga: ang "kaliwang kamay na mobiletto"
359
- ay ang bagay na itinatalaga sa (naka-mirror na data na nakasulat), at ang "right-hand mobiletto" (ang
360
- argumento sa `mirror` method) ay ang value na itinalaga (nabasa ang naka-mirror na data).
361
-
362
- ## Transparent na pag-encrypt
363
- Paganahin ang transparent na client-side 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
- Anong nangyayari? Sinusubaybayan ng isang hiwalay na "pagpasok ng direktoryo" (dirent) na direktoryo (naka-encrypt) kung anong mga file ang naroroon
383
- direktoryo (aka ang direktang direktoryo).
384
- * Ang utos `list` nagbabasa ng mga file ng entry sa direktoryo, nagde-decrypt sa bawat landas na nakalista; pagkatapos ay nagbabalik ng metadata para sa bawat file
385
- * Ang mga utos `list` ay mas hindi epektibo, lalo na para sa mga direktoryo na may malaking bilang ng mga file
386
- * Ang utos `write` nagsusulat ng mga dirent na file sa direktoryo ng bawat magulang, nang paulit-ulit; pagkatapos ay isinusulat ang file
387
- * Ang mga command `write` ay magkakaroon ng O(N) writes, na may N = depth sa hierarchy ng direktoryo
388
- * Tinatanggal ng utos `remove` ang kaukulang dirent file, at ang magulang nito kung walang laman, recursively; pagkatapos ay tanggalin ang file
389
- * Ang mga non-recursive na `remove` command ay magkakaroon ng O(N) reads at posibleng kasing dami ng delete, na may N = depth sa directory hierarchy
390
- * `remove` command sa malaki at malalalim na filesystem ay maaaring magastos
391
-
392
- Tandaan na kahit na naka-enable ang client-side encryption, isang kalaban na may ganap na visibility sa iyong naka-encrypt na server-side
393
- imbakan, kahit na wala ang susi, ay makikita pa rin ang kabuuang bilang ng mga direktoryo at kung gaano karaming mga file ang nasa bawat isa, at kasama
394
- ilang pagsisikap, tuklasin ang ilan o lahat ng pangkalahatang istraktura ng hierarchy ng direktoryo.
395
- *Tandaan: Gumamit ng medyo patag na istraktura para sa mas mahusay na seguridad.*
396
- Hindi malalaman ng kalaban ang mga pangalan ng mga direktoryo/file maliban kung alam din nila ang iyong encryption
397
- key o kung hindi man ay matagumpay na na-crack ang encryption. Tapos na lahat ng taya!
398
-
399
- ### Pagganap at pag-cache
400
- Maaaring mabagal ang mga operasyon sa naka-encrypt na storage. Ang mga recursive na listahan at pag-alis ay maaaring maging napakabagal.
401
- Ang pag-cache sa pamamagitan ng redis ay nakakatulong nang malaki, ngunit tandaan na ang cache ay namumula sa anumang pagsusulat o pag-alis.
402
-
403
- ## Pag-ikot ng key
404
- Gumawa ng mobiletto gamit ang iyong bagong key, pagkatapos ay i-mirror ang lumang data dito:
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
- ## Interface ng driver
417
- Ang driver ay anumang JS file na nag-e-export ng function na 'storageClient' na may ganitong lagda:
418
-
419
- function storageClient (key, secret, opts)
420
-
421
- * `key` : isang string, ang iyong API key (para sa `local` driver ito ang base directory)
422
- * `secret` : isang string, ang iyong API secret (maaaring tanggalin para sa `local` driver)
423
- * `opts` : isang object, ang mga katangian ay per-driver:
424
- * Para sa `local` , tinutukoy ng `fileMode` at `dirMode` properties kung paano nilikha ang mga bagong file at direktoryo
425
- * Para sa `s3` , ang `bucket` property ay kinakailangan. Ang mga opsyonal na katangian ay:
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
- Ang bagay na ibinalik ng storageClient function ay dapat tukuyin ang mga function na ito:
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
- ## Pagtotroso
457
- Ginagamit ng Mobiletto ang [winston](https://www.npmjs.com/package/winston) logging library.
458
-
459
- Ang mga log **ay** maglalaman ng mga landas ng file at mga mensahe ng error, ngunit **hindi** maglalaman ng mga susi, lihim,
460
- o anumang iba pang impormasyon sa pagsasaayos ng koneksyon.
461
-
462
- ### Antas ng log
463
- Gamitin ang `MOBILETTO_LOG_LEVEL` environment variable upang itakda ang antas ng log, gamit ang isa
464
- ng mga antas ng `npm` tinukoy sa [https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels)
465
-
466
- Ang default na antas ay `error` . Ang pinaka-verbose na antas ay `silly` , bagama't kasalukuyang mobiletto
467
- ay hindi nagla-log sa mga antas sa ibaba `debug`
468
-
469
- MOBILETTO_LOG_LEVEL=silly # maximum logs!
470
-
471
- ### Log file
472
- Bilang default, nagsusulat ang logger sa console. Upang magpadala ng mga log sa isang file, itakda ang `MOBILETTO_LOG_FILE`
473
- variable ng kapaligiran. Kapag nagla-log sa isang file, hindi na isusulat ang mga log sa console.
474
-
475
- MOBILETTO_LOG_FILE=/var/my_mobiletto_log
476
-
477
- Upang i-off ang pag-log:
478
-
479
- MOBILETTO_LOG_FILE=/dev/null
480
-
481
- </pre>