mobiletto 1.1.10 → 1.1.13

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 (116) hide show
  1. package/README.md +74 -0
  2. package/docs/README.md +113 -0
  3. package/docs/af/README.md +481 -0
  4. package/docs/am/README.md +481 -0
  5. package/docs/ar/README.md +481 -0
  6. package/docs/az/README.md +481 -0
  7. package/docs/be/README.md +481 -0
  8. package/docs/bg/README.md +481 -0
  9. package/docs/bn/README.md +481 -0
  10. package/docs/bs/README.md +481 -0
  11. package/docs/ca/README.md +481 -0
  12. package/docs/ceb/README.md +481 -0
  13. package/docs/co/README.md +481 -0
  14. package/docs/cs/README.md +481 -0
  15. package/docs/cy/README.md +481 -0
  16. package/docs/da/README.md +481 -0
  17. package/docs/de/README.md +481 -0
  18. package/docs/el/README.md +481 -0
  19. package/docs/eo/README.md +481 -0
  20. package/docs/es/README.md +481 -0
  21. package/docs/et/README.md +481 -0
  22. package/docs/eu/README.md +481 -0
  23. package/docs/fa/README.md +481 -0
  24. package/docs/fi/README.md +481 -0
  25. package/docs/fr/README.md +481 -0
  26. package/docs/fy/README.md +481 -0
  27. package/docs/ga/README.md +481 -0
  28. package/docs/gd/README.md +481 -0
  29. package/docs/gl/README.md +481 -0
  30. package/docs/gu/README.md +481 -0
  31. package/docs/ha/README.md +481 -0
  32. package/docs/haw/README.md +481 -0
  33. package/docs/he/README.md +481 -0
  34. package/docs/hi/README.md +481 -0
  35. package/docs/hmn/README.md +481 -0
  36. package/docs/hr/README.md +481 -0
  37. package/docs/ht/README.md +481 -0
  38. package/docs/hu/README.md +481 -0
  39. package/docs/hy/README.md +481 -0
  40. package/docs/id/README.md +481 -0
  41. package/docs/ig/README.md +481 -0
  42. package/docs/is/README.md +481 -0
  43. package/docs/it/README.md +481 -0
  44. package/docs/iw/README.md +481 -0
  45. package/docs/ja/README.md +481 -0
  46. package/docs/jv/README.md +481 -0
  47. package/docs/ka/README.md +481 -0
  48. package/docs/kk/README.md +481 -0
  49. package/docs/km/README.md +481 -0
  50. package/docs/kn/README.md +481 -0
  51. package/docs/ko/README.md +481 -0
  52. package/docs/ku/README.md +481 -0
  53. package/docs/ky/README.md +481 -0
  54. package/docs/la/README.md +481 -0
  55. package/docs/lb/README.md +481 -0
  56. package/docs/lo/README.md +481 -0
  57. package/docs/lt/README.md +481 -0
  58. package/docs/lv/README.md +481 -0
  59. package/docs/mg/README.md +481 -0
  60. package/docs/mi/README.md +481 -0
  61. package/docs/mk/README.md +481 -0
  62. package/docs/ml/README.md +481 -0
  63. package/docs/mn/README.md +481 -0
  64. package/docs/mr/README.md +481 -0
  65. package/docs/ms/README.md +481 -0
  66. package/docs/mt/README.md +481 -0
  67. package/docs/my/README.md +481 -0
  68. package/docs/ne/README.md +481 -0
  69. package/docs/nl/README.md +481 -0
  70. package/docs/no/README.md +481 -0
  71. package/docs/ny/README.md +481 -0
  72. package/docs/or/README.md +481 -0
  73. package/docs/pa/README.md +481 -0
  74. package/docs/pl/README.md +481 -0
  75. package/docs/ps/README.md +481 -0
  76. package/docs/pt/README.md +481 -0
  77. package/docs/ro/README.md +481 -0
  78. package/docs/ru/README.md +481 -0
  79. package/docs/rw/README.md +481 -0
  80. package/docs/sd/README.md +481 -0
  81. package/docs/si/README.md +481 -0
  82. package/docs/sk/README.md +481 -0
  83. package/docs/sl/README.md +481 -0
  84. package/docs/sm/README.md +481 -0
  85. package/docs/sn/README.md +481 -0
  86. package/docs/so/README.md +481 -0
  87. package/docs/sq/README.md +481 -0
  88. package/docs/sr/README.md +481 -0
  89. package/docs/st/README.md +481 -0
  90. package/docs/su/README.md +481 -0
  91. package/docs/sv/README.md +481 -0
  92. package/docs/sw/README.md +481 -0
  93. package/docs/ta/README.md +481 -0
  94. package/docs/te/README.md +481 -0
  95. package/docs/tg/README.md +481 -0
  96. package/docs/th/README.md +481 -0
  97. package/docs/tk/README.md +481 -0
  98. package/docs/tl/README.md +481 -0
  99. package/docs/tr/README.md +481 -0
  100. package/docs/tt/README.md +481 -0
  101. package/docs/ug/README.md +481 -0
  102. package/docs/uk/README.md +481 -0
  103. package/docs/ur/README.md +481 -0
  104. package/docs/uz/README.md +481 -0
  105. package/docs/vi/README.md +481 -0
  106. package/docs/xh/README.md +481 -0
  107. package/docs/yi/README.md +481 -0
  108. package/docs/yo/README.md +481 -0
  109. package/docs/zh/README.md +481 -0
  110. package/docs/zu/README.md +481 -0
  111. package/drivers/b2/index.js +25 -6
  112. package/hokey.json +16 -0
  113. package/index.js +7 -2
  114. package/package.json +1 -1
  115. package/test/api.spec.js +13 -9
  116. package/util/redis.js +2 -2
@@ -0,0 +1,481 @@
1
+ Mobiletto
2
+ =========
3
+
4
+ Ang Mobiletto usa ka JavaScript storage abstraction layer, nga adunay opsyonal nga transparent nga client-side encryption.
5
+
6
+ # Mga sulud
7
+ * [Nganong Mobiletto?](#Why-Mobiletto?)
8
+ * [Dali nga pagsugod](#Dali nga pagsugod)
9
+ * [Mobiletto CLI](#mobiletto-cli)
10
+ * [Source](#Source)
11
+ * [Pag-instalar](#Pag-instalar)
12
+ * [Pagsuporta ug Pagpondo](#Suporta-ug-Pagpondo)
13
+ * [Basic nga paggamit](#Basic-usage)
14
+ * [Metadata](#Metadata)
15
+ * [Alternate import style](#Alternate-import-style)
16
+ * [Caching](#Caching)
17
+ * [Mirroring](#Mirroring)
18
+ * [Transparent nga encryption](#Transparent-encryption)
19
+ * [Pagtuyok sa yawe](#Rotation sa yawe)
20
+ * [Driver interface](#Driver-interface)
21
+ * [Logging](#Logging)
22
+
23
+ # Basaha kini sa laing pinulongan
24
+ Kining README.md nga dokumento gihubad, pinaagi sa [hokeylization](https://github.com/cobbzilla/hokeylization), ngadto sa
25
+ **[matag pinulongan gisuportahan sa Google Translate](https://cloud.google.com/translate/docs/languages)!**
26
+
27
+ Sigurado ko nga dili kini perpekto, apan nanghinaut ko nga kini mas maayo kaysa wala!
28
+
29
+ [🇸🇦 Arabiko](../ar/README.md)
30
+ [🇧🇩 Bengali](../bn/README.md)
31
+ [🇩🇪 German](../de/README.md)
32
+ [🇺🇸 English](../en/README.md)
33
+ [🇪🇸 Kinatsila](../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
+ [🇯🇵 Hapon](../ja/README.md)
40
+ [🇰🇷 Koreano](../ko/README.md)
41
+ [🇮🇳 Maranthi](../mr/README.md)
42
+ [🇵🇱 Polish](../pl/README.md)
43
+ [🇧🇷 Portuges](../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
+ **[📚 ... Tanang Pinulongan ...](../README.md)**
54
+ ----
55
+
56
+ ### Aduna bay problema sa kini nga paghubad sa README?
57
+ Kining partikular nga hubad sa orihinal [README](https://github.com/cobbzilla/mobiletto/blob/master/README.md)
58
+ mahimong depekto -- *ang mga pagkorihir kay abi-abi kaayo!* Palihog ipadala ug [pull request sa GitHub](https://github.com/cobbzilla/mobiletto/pulls),
59
+ o kung dili ka komportable nga buhaton kana, [ablihi ang usa ka isyu](https://github.com/cobbzilla/mobiletto/issues)
60
+
61
+ Kung maghimo ka usa ka bag-ong isyu sa GitHub bahin sa usa ka paghubad, palihug buhata:
62
+ * Ilakip ang URL sa panid (kopya / idikit gikan sa address bar sa browser)
63
+ * Ilakip ang eksakto nga teksto nga sayup (kopya / idikit gikan sa browser)
64
+ * palihug ihulagway kung unsa ang sayup -- sayop ba ang paghubad? naguba ba ang pag-format sa usa ka paagi?
65
+ * malulotong maghatag ug sugyot sa mas maayong hubad, o kon sa unsang paagi ang teksto kinahanglang hustong maporma
66
+ * **Salamat!**
67
+
68
+ ## Nganong Mobiletto?
69
+
70
+ ### Goodbye vendor lock-in!
71
+ Ang lain-laing mga cloud storage providers adunay mga dili compatible nga mga API. Bisan kadtong naningkamot alang sa "S3 compatibility"
72
+ adunay idiosyncratic nga mga kinaiya.
73
+
74
+ Kung nagpili ka usa ka partikular nga tigbaligya sa pagtipig alang sa imong app, kung direkta ka nga mag-code sa ilang API, ang imong app
75
+ nagdepende na karon sa maong serbisyo. Sa paglabay sa panahon ug ang code natipon, ang pagbag-o sa mga tigbaligya mahimong
76
+ nagkadaghan nga dili mapadayon. Welcome sa makalingaw nga kalibutan sa vendor lock-in!
77
+
78
+ Gidisenyo ang Mobiletto aron masulbad kini nga problema. Pinaagi sa pag-coding sa imong app sa mobiletto's API, dali ka
79
+ usba ang mga taghatag sa pagtipig ug hibal-i nga ang layer sa pagtipig sa imong app parehas nga molihok.
80
+
81
+ ### Daghang pagsulay
82
+ Ang tanan nga mga drayber gisulayan alang sa parehas nga pamatasan nga adunay 60+ nga mga pagsulay alang sa matag drayber.
83
+ Gisulayan namon ang tanan nga mga drayber sa matag kombinasyon sa:
84
+ * Pag-encrypt: pareho nga gi-enable ug gi-disable
85
+ * Redis cache: pareho nga gi-enable ug gi-disable
86
+
87
+ Kini nga pamaagi naghatag kanato og kalinaw sa hunahuna nga ang mobiletto molihok nga parehas bisan unsa nga drayber ang imong gigamit,
88
+ ug dili igsapayan kung mahimo nimo ang pag-cache ug/o pag-encrypt.
89
+
90
+ ### Suporta sa drayber
91
+ Kasamtangang mga drayber sa pagtipig sa Mobiletto:
92
+ * `s3` : Amazon S3
93
+ * `b2` : Backblaze B2
94
+ * `local` : lokal nga filesystem
95
+
96
+ *Ang mga kontribusyon sa pagsuporta sa mas daghang cloud storage providers giabiabi kaayo!*
97
+
98
+ ## mobiletto-cli
99
+ Ang Mobiletto gituyo nga gamiton isip librarya sa ubang JavaScript code.
100
+
101
+ Aron magtrabaho sa mobiletto sa command-line, gamita ang [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)
102
+
103
+ ## Tinubdan
104
+ * [mobiletto sa GitHub](https://github.com/cobbzilla/mobiletto)
105
+ * [mobiletto sa npm](https://www.npmjs.com/package/mobiletto)
106
+
107
+ ## Suporta ug Pagpundo
108
+ Ako naningkamot nga mahimong usa ka propesyonal nga open source software developer. Nagtrabaho ko sa
109
+ ang industriya sa software sulod sa daghang katuigan, nagsugod ko og malampusong mga kompanya ug gibaligya kini sa mga publikong kompanya.
110
+ Bag-o lang nawad-an kog trabaho, ug wala na gyud koy laing trabaho nga nakalinya
111
+
112
+ Mao nga sulayan nako ang pagsulat sa makatabang nga software ug tan-awon kung kini molihok
113
+
114
+ Kung malingaw ka sa paggamit niini nga software, mapasalamaton kaayo ko bisan sa
115
+ pinakagamay [binulan nga kontribusyon pinaagi sa Patreon](https://www.patreon.com/cobbzilla)
116
+
117
+ *Salamat!*
118
+
119
+ ## Pag-instalar
120
+ I-install gamit ang `npm` o `yarn` . Tingali gusto nimo ang `lite` nga bersyon nga wala maglakip sa tanan nga
121
+ gihubad nga README nga mga file:
122
+
123
+ npm install mobiletto-lite
124
+ yarn add mobiletto-lite
125
+
126
+ Kung gusto gyud nimo ang README nga mga file sa matag lengguwahe, i-install ang tibuuk nga bersyon:
127
+
128
+ npm install mobiletto
129
+ yarn add mobiletto
130
+
131
+ ## Dali nga Pagsugod
132
+ Usa ka mubo nga pananglitan gamit ang mobiletto `s3` driver.
133
+
134
+ Kini nga code modagan nga parehas kung ang drayber `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
+ ## Basic nga paggamit
165
+ Usa ka labi ka halapad nga pananglitan, nga nagpakita sa kadaghanan sa mga bahin nga gitanyag:
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 `metadata` sugo nagbalik sa metadata mahitungod sa usa ka filesystem entry.
268
+ Ingon usab, ang pagbalik nga kantidad gikan sa `list` sugo usa ka han-ay sa metadata nga mga butang.
269
+
270
+ Ang usa ka butang nga metadata ingon niini:
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 `type` property mahimong `file` , `dir` , `link` , o `special` .
281
+
282
+ Depende sa matang sa drayber, ang usa ka `list` nga sugo mahimong dili ibalik ang tanang field. Ang `name` ug `type` nga mga kabtangan
283
+ kinahanglan nga anaa kanunay. Ang sunod nga `metadata` sugo ibalik ang tanan nga magamit nga kabtangan.
284
+
285
+ ## Kapuli nga istilo sa import
286
+ I-import ang fully-scoped module ug gamita 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
+ Ang Mobiletto labing maayo sa usa ka <a href="https://redis.io">redis</a> cache.
295
+
296
+ Ang Mobiletto mosulay sa pagkonektar sa usa ka redis nga pananglitan sa 127.0.0.1:6379
297
+
298
+ Mahimo nimong i-override ang bisan hain niini:
299
+ * Ibutang ang `MOBILETTO_REDIS_HOST` env var, mobiletto magkonektar dinhi imbes nga localhost
300
+ * Ibutang ang `MOBILETTO_REDIS_PORT` env var, kini nga pantalan gamiton
301
+
302
+ Itago sa Mobiletto ang tanan nga mga yawe sa redis nga adunay prefix nga `_mobiletto__` . Mahimo nimong usbon kini
303
+ pinaagi sa pagbutang sa `MOBILETTO_REDIS_PREFIX` env var.
304
+
305
+ Mahimo usab nimong itakda ang caching matag koneksyon gamit ang butang nga `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
+ ### Dili gusto redis caching?
317
+ Aron ma-disable: ipasa `enabled: false` sa imong `opts.redisConfig` nga butang kung imong maestablisar ang imong koneksyon.
318
+
319
+ Sama sa gihisgutan sa ubos, ang pag-disable sa caching adunay dili maayo nga epekto sa pasundayag ug adunay daghang mga hangyo
320
+ sa pagtipig nga kinahanglan gyud nimo.
321
+
322
+ ### Giya sa pag-cache
323
+ **Naka-encrypt nga storage**: ang pagbasa/pagsulat sa na-encrypt nga storage mas hinay lang kay sa normal,
324
+ apan ang pag-navigate sa mga direktoryo (nga gibuhat sa pipila ka mga butang) medyo mahal. Paggamit sa redis cache
325
+ maghatag kanimo usa ka hinungdanon nga pagpauswag sa pasundayag.
326
+
327
+ Ang default nga cache luwas, apan dili maayo kung ikaw adunay daghang mga operasyon sa pagsulat / pagtangtang.
328
+ Ang bisan unsang pagsulat o pagtangtang nga operasyon dili balido sa tibuuk nga cache, pagsiguro nga ang mga sunod nga pagbasa makakita sa
329
+ pinakabag-o nga mga pagbag-o.
330
+
331
+ ### CLI nga mga himan
332
+ Kung naggamit ka ug CLI tool sama sa [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
333
+ siguradong gusto nimo nga ma-enable ang redis cache, tungod kay molungtad kini sa mga pag-ampo sa `mo` mando.
334
+
335
+ ## Pagsalamin
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 `mirror` sugo naghimo sa usa ka higayon nga kopya sa tanang mga file gikan sa usa ka mobiletto ngadto sa lain.
344
+ Wala kini nagpadagan sa bisan unsang proseso aron mapadayon ang salamin sa paglabay sa panahon. Dagan pag-usab ang `mirror` sugo
345
+ aron ma-synchronize ang bisan unsang nawala nga mga file.
346
+
347
+ Ang gibalik nga bili gikan sa `mirror` kay usa ka yano nga butang nga adunay mga counter kung pila ka file ang malampuson
348
+ gisalamin ug pila ka mga file ang adunay mga sayup:
349
+
350
+ {
351
+ success: count-of-files-mirrored,
352
+ errors: count-of-files-with-errors
353
+ }
354
+
355
+ WARNING: Ang pagsalamin sa dagkong mga set sa datos mahimong makahurot ug panahon ug kusog sa bandwidth
356
+
357
+ Uban sa `mirror` tawag semantics kini usahay makalibog sa pagsabut kon kinsa ang
358
+ magbabasa ug kinsa ang magsusulat. Hunahunaa kini sama sa usa ka pahayag sa assignment: ang "left-hand mobiletto"
359
+ mao ang butang nga gi-assign sa (mirrored data nga gisulat), ug ang "right-hand mobiletto" (ang
360
+ argumento sa `mirror` nga pamaagi) mao ang bili nga gi-assign (gibasa ang salamin nga datos).
361
+
362
+ ## Transparent nga encryption
363
+ I-enable ang transparent nga 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
+ Unsay nahitabo? Ang usa ka bulag nga "direktoryo nga pagsulod" (direkta) nga direktoryo (na-encrypt) nagsubay kung unsang mga file ang naa niana
383
+ direktoryo (aka ang direksiyon nga direktoryo).
384
+ * Ang `list` sugo nagbasa sa mga file sa pagsulod sa direktoryo, nag-decrypt sa matag dalan nga gilista; unya ibalik ang metadata alang sa matag file
385
+ * `list` nga mga sugo mas dili epektibo, ilabi na sa mga direktoryo nga adunay daghang mga file
386
+ * Ang `write` sugo mosulat sa mga dirent files sa matag ginikanan nga direktoryo, balikbalik; unya isulat ang file
387
+ * Ang mga sugo sa `write` adunay O(N) nga pagsulat, nga adunay N = giladmon sa hierarchy sa direktoryo
388
+ * Ang `remove` command nagtangtang sa katugbang nga dirent file, ug ang ginikanan niini kung walay sulod, balikbalik; unya tangtangon ang file
389
+ * Ang non-recursive nga `remove` mga sugo makaangkon og O(N) nga mga pagbasa ug posibleng sama kadaghan sa mga pagtangtang, nga adunay N = giladmon sa directory hierarchy
390
+ * Ang mga recursive nga `remove` mga sugo sa dagko ug lawom nga mga filesystem mahimong mahal
391
+
392
+ Hinumdumi nga bisan kung gipaandar ang pag-encrypt sa kilid sa kliyente, usa ka kontra nga adunay hingpit nga panan-aw sa imong naka-encrypt nga bahin sa server.
393
+ storage, bisan wala ang yawe, makita gihapon ang kinatibuk-ang gidaghanon sa mga direktoryo ug pila ka mga file ang anaa sa matag usa, ug uban pa
394
+ pipila ka paningkamot, pagdiskobre sa pipila o sa tanan nga kinatibuk-ang istruktura sa hierarchy sa direktoryo.
395
+ *Pahinumdom: Paggamit ug medyo patag nga estraktura para sa mas maayong seguridad.*
396
+ Dili mahibal-an sa kaaway ang mga ngalan sa mga direktoryo / file gawas kung nahibal-an usab nila ang imong pag-encrypt
397
+ yawe o malampuson nga na-crack ang encryption. Ang tanan nga pusta wala na unya!
398
+
399
+ ### Pagganap ug pag-cache
400
+ Ang mga operasyon sa naka-encrypt nga pagtipig mahimong hinay. Ang mga recursive nga listahan ug pagtangtang mahimong hinay kaayo.
401
+ Ang pag-cache pinaagi sa redis makatabang kaayo, apan timan-i nga ang cache na-flush sa bisan unsang pagsulat o pagtangtang.
402
+
403
+ ## Key rotation
404
+ Paghimo og mobiletto gamit ang imong bag-ong yawe, dayon i-salamin ang daan nga datos niini:
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 sa drayber
417
+ Ang usa ka drayber mao ang bisan unsang JS file nga nag-eksport sa usa ka 'storageClient' function uban niini nga pirma:
418
+
419
+ function storageClient (key, secret, opts)
420
+
421
+ * `key` : usa ka string, ang imong API key (para sa `local` nga drayber kini ang base nga direktoryo)
422
+ * `secret` : usa ka string, ang imong API secret (mahimong tangtangon para sa `local` driver)
423
+ * `opts` : usa ka butang, ang mga kabtangan kay per-driver:
424
+ * Para sa `local` , ang `fileMode` ug `dirMode` nga mga propyedad nagtino kung giunsa paghimo ang bag-ong mga file ug direktoryo
425
+ * Para sa `s3` , gikinahanglan ang `bucket` nga kabtangan. Opsyonal nga mga kabtangan mao ang:
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 butang nga gibalik sa storageClient function kinahanglan maghubit niini nga mga gimbuhaton:
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
+ ## Pag-log
457
+ Gigamit ni Mobiletto ang [winston](https://www.npmjs.com/package/winston) logging library.
458
+
459
+ Ang mga log **adunay** mga agianan sa file ug mga mensahe sa sayup, apan **dili gayud** adunay mga yawe, sekreto,
460
+ o bisan unsang ubang impormasyon sa pagsumpo sa koneksyon.
461
+
462
+ ### Log nga lebel
463
+ Gamita ang `MOBILETTO_LOG_LEVEL` environment variable aron itakda ang log level, gamit ang usa
464
+ sa mga lebel sa `npm` nga gihubit sa [https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels)
465
+
466
+ Ang default nga lebel kay `error` . Ang labing verbose nga lebel kay `silly` , bisan sa pagkakaron mobiletto
467
+ wala mag log sa lebel ubos sa `debug`
468
+
469
+ MOBILETTO_LOG_LEVEL=silly # maximum logs!
470
+
471
+ ### Log file
472
+ Sa kasagaran, ang logger nagsulat sa console. Aron ipadala ang mga log sa usa ka file, itakda ang `MOBILETTO_LOG_FILE`
473
+ variable sa palibot. Kung mag-log sa usa ka file, ang mga troso dili na isulat sa console.
474
+
475
+ MOBILETTO_LOG_FILE=/var/my_mobiletto_log
476
+
477
+ Aron i-off ang pag-log:
478
+
479
+ MOBILETTO_LOG_FILE=/dev/null
480
+
481
+ </pre>