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
+ O le Mobiletto o se vaega e teu ai mea e teu ai le JavaScript, fa'atasi ai ma le fa'amalamalamaga manino a le tagata o tausia.
5
+
6
+ # I totonu
7
+ * [Aisea Mobiletto?](#Aisea-Mobiletto?)
8
+ * [Amata vave](#Amata vave)
9
+ * [Mobiletto CLI](#mobiletto-cli)
10
+ * [Source](#Source)
11
+ * [Fa'apipi'i](#Fa'apipi'i)
12
+ * [Lagolago ma le Faatupeina](#Support-and-Funding)
13
+ * [Fa'aoga masani](#Fa'aoga-fa'aoga)
14
+ * [Metadata](#Metadata)
15
+ * [Sui fa'aulufale mai](#Alternate-import-style)
16
+ * [Cach](#Caching)
17
+ * [Fa'ata](#Fa'ata)
18
+ * [Fa'amatalaga manino](#Fa'amatalaga manino)
19
+ * [Tili ki ki](#Tili-ki)
20
+ * [Ataavale ta'avale](#Fa'aoga-taavale)
21
+ * [Logging](#Logging)
22
+
23
+ # Faitau lenei i se isi gagana
24
+ O lenei README.md pepa ua faaliliuina, e ala i le [hokeylization](https://github.com/cobbzilla/hokeylization), i totonu
25
+ **[gagana uma e lagolagoina e Google Translate](https://cloud.google.com/translate/docs/languages)!**
26
+
27
+ Ou te mautinoa e le atoatoa, ae ou te faʻamoemoe e sili atu nai lo le leai!
28
+
29
+ [🇸🇦 Alapi](../ar/README.md)
30
+ [🇧🇩 Bengali](../bn/README.md)
31
+ [🇩🇪 Siamani](../de/README.md)
32
+ [🇺🇸 Igilisi](../en/README.md)
33
+ [🇪🇸 Sipaniolo](../es/README.md)
34
+ [🇫🇷 Farani](../fr/README.md)
35
+ [🇹🇩 Hausa](../ha/README.md)
36
+ [🇮🇳 Hindi](../hi/README.md)
37
+ [🇮🇩 Initonesia](../id/README.md)
38
+ [🇮🇹 Italia](../it/README.md)
39
+ [🇯🇵 Iapani](../ja/README.md)
40
+ [🇰🇷 Korea](../ko/README.md)
41
+ [🇮🇳 Maranthi](../mr/README.md)
42
+ [🇵🇱 Polani](../pl/README.md)
43
+ [🇧🇷 Potukale](../pt/README.md)
44
+ [🇷🇺 Rusia](../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
+ [🇨🇳 Saina](../zh/README.md)
51
+
52
+
53
+ **[📚 ... Gagana Uma ...](../README.md)**
54
+ ----
55
+
56
+ ### E iai se fa'afitauli i lenei fa'aliliuga o le README?
57
+ Lenei fa'aliliuga fa'apitoa o le ulua'i [README](https://github.com/cobbzilla/mobiletto/blob/master/README.md)
58
+ atonu e sese -- *fa'asa'oga e matua talia lava!* Fa'amolemole lafo mai se [talosaga toso ile GitHub](https://github.com/cobbzilla/mobiletto/pulls),
59
+ pe afai e te le fiafia e fai lena mea, [tatala se mataupu](https://github.com/cobbzilla/mobiletto/issues)
60
+
61
+ A e fatuina se lomiga fou GitHub e uiga i se faaliliuga, faamolemole fai:
62
+ * fa'aaofia ai le itulau URL (kopi/pa'i mai le tuatusi tuatusi pa)
63
+ * fa'aaofia ai le fa'amatalaga sa'o e sese (kopi/pa'i mai le su'esu'ega)
64
+ * fa'amolemole fa'amatala le mea o lo'o fa'aletonu -- e le sa'o le fa'aliliuga? ua malepe le faatulagaga?
65
+ * ofo mai ma le agalelei se fautuaga o se faaliliuga e sili atu, po o le auala e tatau ona faatulaga lelei ai le tusitusiga
66
+ * **Faafetai!**
67
+
68
+ ## Aisea Mobiletto?
69
+
70
+ ### Tofa le tagata faatau loka-i totonu!
71
+ O le tele o mea e teu ai ao e iai API e le fetaui. E oʻo lava ia i latou o loʻo taumafai mo le "S3 compatibility"
72
+ e iai uiga fa'apitoa.
73
+
74
+ A e filifilia se fa'atau oloa teu mo lau app, pe a e fa'ailoga sa'o i la latou API, lau app
75
+ ua faalagolago nei i lea auaunaga. A'o alu le taimi ma fa'aputuina le code, o le a suia tagata fa'atau
76
+ ua faateleina le le mafaia. Faʻafeiloaʻi i le lalolagi malie o le faʻatau loka-i totonu!
77
+
78
+ Mobiletto na fuafuaina e foia lenei faafitauli. I le fa'ailogaina o lau app ile mobiletto's API, e faigofie
79
+ sui kamupani teu oloa ma iloa o le a tutusa le amio a lau app.
80
+
81
+ ### Su'ega tele
82
+ O aveta'avale uma e fa'ata'ita'iina mo uiga tutusa ma le 60+ su'ega mo ta'avale ta'itasi.
83
+ Matou te suʻeina avetaʻavale uma i tuʻufaʻatasiga uma o:
84
+ * Fa'ailoga: e mafai uma ma fa'aletonu
85
+ * Redis cache: mafai uma ma le le atoatoa
86
+
87
+ O lenei faiga e maua ai le filemu o le mafaufau o le mobiletto o le a amio tutusa tusa lava po o le a le avetaavale e te faʻaaogaina,
88
+ ma e tusa lava pe e te faʻaogaina le faʻaogaina ma/poʻo le faʻailoga.
89
+
90
+ ### Lagolago avetaavale
91
+ Avetaavale teuina Mobiletto nei:
92
+ * `s3` : Amazon S3
93
+ * `b2` : Backblaze B2
94
+ * `local` : faiga faila fa'apitonu'u
95
+
96
+ *O sao e lagolago ai le tele o kamupani e teu ai ao e matua talia!*
97
+
98
+ ## mobiletto-cli
99
+ Mobiletto ua fa'amoemoe e fa'aoga e fai ma faletusi e isi code JavaScript.
100
+
101
+ Ina ia galue ma mobiletto i le laina-faʻatonu, faʻaaoga [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)
102
+
103
+ ## Punavai
104
+ * [mobiletto i luga ole GitHub](https://github.com/cobbzilla/mobiletto)
105
+ * [mobiletto on npm](https://www.npmjs.com/package/mobiletto)
106
+
107
+ ## Lagolago ma Faatupeina
108
+ O lo'o ou taumafai e avea a'u ma se tagata fa'apolofesa fa'apolofesa fa'apolofesa matala. Sa ou galue i totonu
109
+ le pisinisi faakomepiuta mo le tele o tausaga, ua ou amataina kamupani manuia ma faatau atu i kamupani lautele.
110
+ Talu ai nei na ou leiloa ai laʻu galuega, ma e leai lava se isi galuega o loʻo faʻatulagaina
111
+
112
+ O lea o le a ou taumafai e tusi le polokalama fesoasoani ma vaai pe aoga
113
+
114
+ Afai e te fiafia e faʻaaoga lenei polokalama, ou te matua faʻafetai lava mo le
115
+ aupito itiiti [saomea faalemasina e ala i Patreon](https://www.patreon.com/cobbzilla)
116
+
117
+ *Faafetai!*
118
+
119
+ ## Fa'apipi'i
120
+ Fa'apipi'i fa'aaoga `npm` po'o `yarn` . Atonu e te mana'o i le `lite` version e le aofia uma ai
121
+ fa'aliliu faila README:
122
+
123
+ npm install mobiletto-lite
124
+ yarn add mobiletto-lite
125
+
126
+ Afai e te manaʻo moni i faila README i gagana uma, faʻapipiʻi le faʻasologa atoa:
127
+
128
+ npm install mobiletto
129
+ yarn add mobiletto
130
+
131
+ ## Amata vave
132
+ O se fa'ata'ita'iga pu'upu'u e fa'aaoga ai le aveta'avale mobiletto `s3` .
133
+
134
+ E tutusa le fa'aogaina o lenei code pe afai o le aveta'avale o le `b2` po'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
+ ## Fa'aoga masani
165
+ O se faʻataʻitaʻiga sili atu ona lautele, faʻaalia le tele o foliga o loʻo ofoina atu:
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
+ O le `metadata` poloaiga e toe fa'afo'i mai metadata e uiga i se faila faila e tasi.
268
+ E fa'apea fo'i, o le tau fa'afo'i mai le `list` fa'atonuga o se fa'asologa o mea metadata.
269
+
270
+ O se mea metadata e pei o lenei:
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
+ O le meatotino `type` e mafai ona avea ma `file` , `dir` , `link` , po'o `special` .
281
+
282
+ Fa'alagolago ile ituaiga aveta'avale, ole `list` fa'atonuga e le mafai ona toe fa'afo'i uma fanua. Le `name` ma `type` meatotino
283
+ e tatau ona i ai i taimi uma. Ole fa'atonuga ole `metadata` ole a toe fa'afo'i uma meatotino avanoa.
284
+
285
+ ## Su'i faiga fa'aulufale mai
286
+ Fa'aulufale mai le fa'aoga atoa ma fa'aoga le `connect` galuega:
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
+ ## Fa'asao
294
+ E sili ona aoga le Mobiletto i le <a href="https://redis.io">redis</a> cache.
295
+
296
+ Mobiletto o le a taumafai e faʻafesoʻotaʻi i se redis faʻataʻitaʻiga ile 127.0.0.1:6379
297
+
298
+ E mafai ona e suia se tasi o mea nei:
299
+ * Seti le `MOBILETTO_REDIS_HOST` env var, mobiletto fesootai iinei nai lo localhost
300
+ * Seti le `MOBILETTO_REDIS_PORT` env var, o le a fa'aoga lenei uafu
301
+
302
+ Mobiletto o le a teuina uma ana ki redis ma le prefix `_mobiletto__` . E mafai ona e suia lenei mea
303
+ e ala i le setiina o le `MOBILETTO_REDIS_PREFIX` env var.
304
+
305
+ E mafai fo'i ona e setiina le fa'aogaina o feso'ota'iga ma le mea `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
+ ### E te le manaʻo e toe faʻapipiʻi faʻailoga?
317
+ E fa'agata: pasi `enabled: false` i lau `opts.redisConfig` mea pe a e fa'atuina lau feso'ota'iga.
318
+
319
+ E pei ona talanoaina i lalo, o le tapeina o le caching o le a i ai se aafiaga leaga i le faatinoga ma maua ai nisi talosaga
320
+ i le teuina e te manaʻomia moni lava.
321
+
322
+ ### Ta'iala fa'asao
323
+ **Teuga fa'aigoa**: faitau/tusitusi fa'ailoga fa'ailoga e fa'agesegese teisi nai lo le masani,
324
+ ae o le fa'ata'amilo i fa'atonuga (lea e fai e nisi mea) e fai si taugata. Faʻaaogaina o le redis cache
325
+ o le a tu'uina atu ia te oe se fa'aopoopoga taua tele.
326
+
327
+ O le fa'aoga fa'aoga e saogalemu, ae e le lelei pe afai e tele au tusitusi/ave'ese galuega.
328
+ So'o se tusi pe aveese fa'agaioiga e fa'aleaogaina ai le fa'aoga atoa, fa'amautinoa o le a va'aia e faitauga mulimuli ane le
329
+ suiga lata mai.
330
+
331
+ ### CLI meafaigaluega
332
+ Afai o lo'o e fa'aogaina se meafaigaluega CLI pei o le [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
333
+ e mautinoa lava e te mana'o e fa'aaga le cache redis, aua e tumau i le fa'atonuga o le `mo` command.
334
+
335
+ ## Fa'ata
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
+ O le `mirror` fa'atonuga e faia se kopi tasi taimi o faila uma mai le tasi mobiletto i le isi.
344
+ E leai se faiga e fa'atumauina ai le fa'ata ile taimi. Toe fa'atonu le `mirror`
345
+ e fa'amaopoopo so'o se faila e misi.
346
+
347
+ O le tau fa'afo'i mai `mirror` o se mea faigofie ma fa'atau mo le tele o faila na manuia
348
+ fa'ata ma pe fia faila na iai mea sese:
349
+
350
+ {
351
+ success: count-of-files-mirrored,
352
+ errors: count-of-files-with-errors
353
+ }
354
+
355
+ LAPATA'IGA: O le fa'ataina o seti fa'amaumauga tetele e mafai ona alu tele le taimi ma fa'ato'a tele le bandwidth
356
+
357
+ Faatasi ai ma le `mirror` valaau semantics e mafai i nisi taimi ona fenumiai le malamalama po o ai le
358
+ tagata faitau ma o ai le tusitala. Vaʻai faalemafaufau e pei o se faʻamatalaga o tofiga: o le "lima agavale mobiletto"
359
+ o le mea o loʻo tuʻuina atu i (faʻata faʻamatalaga tusia), ma le "lima taumatau mobiletto" (le
360
+ finauga i le `mirror` auala) o le tau o loʻo tuʻuina atu (faʻata faʻamatalaga faitau).
361
+
362
+ ## Fa'amatalaga manino
363
+ Fa'aagaioi le fa'amalamalamaga manino le itu o tagata o tausia:
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
+ O le a le mea o tupu? O se isi fa'asinomaga "fa'asinomaga" (dirent) fa'ailoga (fa'ailoga) e su'e ai faila o lo'o i ai
383
+ directory (a'o le directory directory).
384
+ * O le `list` poloaiga e faitau ai faila fa'amaufa'ailoga, fa'ate'aina ala ta'itasi o lo'o lisiina; ona toe faafoi mai lea o metadata mo faila taitasi
385
+ * `list` poloaiga e sili atu le le lelei, aemaise lava mo faʻamaumauga e tele faila
386
+ * O le fa'atonuga `write` tusi' e tusia ai faila eseese i fa'amaumauga a matua ta'itasi, fa'asolosolo; ona tusi lea o le faila
387
+ * O tulafono `write` o le a maua ai le O(N) tusitusi, ma N = loloto i le fa'atonuga o le lisi.
388
+ * O le fa'atonuga `remove` e aveese ai le faila tu'usa'o, ma lona matua pe a gaogao, fa'asolosolo; ona aveese lea o le faila
389
+ * O tulafono `remove` e le toe fa'afo'isia o le a maua ai le O(N) faitau ma e ono tele fo'i le tapeina, fa'atasi ai ma le N = loloto i le fa'asologa o fa'atonuga.
390
+ * `remove` i luga o faila faila tetele ma loloto e mafai ona taugata
391
+
392
+ Manatua e tusa lava pe fa'amanaia le fa'ailoga tagata o tausia, o se fili ma le va'aia atoatoa i lau 'au'aunaga fa'ailoga.
393
+ teuina, e tusa lava pe leai se ki, e mafai lava ona vaʻaia le aofaʻi o faʻamaumauga ma pe fia faila i totonu taʻitasi, ma faʻatasi
394
+ nisi taumafaiga, su'e nisi po'o le fa'atulagaina atoa o le fa'asologa o fa'atonuga.
395
+ *Manatua: Fa'aoga se fausaga mafolafola mo le saogalemu lelei.*
396
+ O le a le iloa e le fili igoa o directories/faila sei vagana ua latou iloa foi lau fa'ailoga
397
+ ki po'o na fa'asolo manuia le fa'ailoga. Ua uma loa peti uma!
398
+
399
+ ### Fa'atinoga ma le fa'aoga
400
+ E mafai ona faagesegese le fa'agaioiga i luga o le teuina fa'ailoga. E mafai ona telegese le fa'asologa o lisi ma aveese.
401
+ E fesoasoani tele le fa'asaoina e ala i le redis, ae ia maitauina o lo'o fa'afefe le cache i luga o so'o se tusitusiga pe aveese.
402
+
403
+ ## Fa'aliliuga ki
404
+ Fausia se mobiletto i lau ki fou, ona faʻataʻitaʻi lea o faʻamaumauga tuai i totonu:
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
+ ## Fa'atonu aveta'avale
417
+ O le aveta'avale o so'o se faila JS e auina atu i fafo se galuega 'storageClient' ma lenei saini:
418
+
419
+ function storageClient (key, secret, opts)
420
+
421
+ * `key` : o se manoa, lau ki API (mo le `local` aveta'avale o le lisi autu lea)
422
+ * `secret` : o se manoa, lau API mealilo (e mafai ona aveese mo le avetaavale `local` )
423
+ * `opts` : o se mea, o meatotino e ta'i-taavale:
424
+ * Mo `local` , o le `fileMode` ma `dirMode` meatotino e fuafua ai pe fa'afefea ona faia faila fou ma fa'atonuga.
425
+ * Mo `s3` , e mana'omia le meatotino `bucket` . O meatotino e filifili ai o:
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
+ O le mea e toe faʻafoʻi mai e le storageClient galuega e tatau ona faʻamalamalamaina galuega nei:
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
+ ## Loka
457
+ E fa'aoga e Mobiletto le faletusi talatala [winston](https://www.npmjs.com/package/winston).
458
+
459
+ O ogalaau **o le a** iai ala faila ma feʻau sese, ae o le a **leai lava** iai ki, mealilo,
460
+ po'o so'o se isi fa'amatalaga fa'aopoopo feso'ota'iga.
461
+
462
+ ### Tulaga ogalaau
463
+ Fa'aoga le suiga ole siosiomaga `MOBILETTO_LOG_LEVEL` e seti ai le maualuga o ogalaau, fa'aaoga le tasi
464
+ o tulaga `npm` o lo'o fa'amatalaina i le [https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels)
465
+
466
+ Ole tulaga fa'aletonu ole `error` . Ole la'asaga pito sili ona tautala ole `silly` , e ui o le taimi nei o le mobiletto
467
+ e le fa'amauina i tulaga i lalo ole `debug`
468
+
469
+ MOBILETTO_LOG_LEVEL=silly # maximum logs!
470
+
471
+ ### Faila faila
472
+ Ona o le faaletonu, e tusi le logger i le faamafanafanaga. Ina ia lafo atu ogalaau i se faila, seti le `MOBILETTO_LOG_FILE`
473
+ fesuiaiga o le siosiomaga. A o'o i se faila, o le a le toe tusia ni ogalaau i le fa'amafanafanaga.
474
+
475
+ MOBILETTO_LOG_FILE=/var/my_mobiletto_log
476
+
477
+ Ina ia tape le laiga:
478
+
479
+ MOBILETTO_LOG_FILE=/dev/null
480
+
481
+ </pre>