mobiletto 1.1.8 → 1.1.11

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 (117) hide show
  1. package/README.md +56 -4
  2. package/docs/README.md +113 -0
  3. package/docs/af/README.md +455 -0
  4. package/docs/am/README.md +455 -0
  5. package/docs/ar/README.md +455 -0
  6. package/docs/az/README.md +455 -0
  7. package/docs/be/README.md +455 -0
  8. package/docs/bg/README.md +455 -0
  9. package/docs/bn/README.md +455 -0
  10. package/docs/bs/README.md +455 -0
  11. package/docs/ca/README.md +455 -0
  12. package/docs/ceb/README.md +455 -0
  13. package/docs/co/README.md +455 -0
  14. package/docs/cs/README.md +455 -0
  15. package/docs/cy/README.md +455 -0
  16. package/docs/da/README.md +455 -0
  17. package/docs/de/README.md +455 -0
  18. package/docs/el/README.md +455 -0
  19. package/docs/eo/README.md +455 -0
  20. package/docs/es/README.md +455 -0
  21. package/docs/et/README.md +455 -0
  22. package/docs/eu/README.md +455 -0
  23. package/docs/fa/README.md +455 -0
  24. package/docs/fi/README.md +455 -0
  25. package/docs/fr/README.md +455 -0
  26. package/docs/fy/README.md +455 -0
  27. package/docs/ga/README.md +455 -0
  28. package/docs/gd/README.md +455 -0
  29. package/docs/gl/README.md +455 -0
  30. package/docs/gu/README.md +455 -0
  31. package/docs/ha/README.md +455 -0
  32. package/docs/haw/README.md +455 -0
  33. package/docs/he/README.md +455 -0
  34. package/docs/hi/README.md +455 -0
  35. package/docs/hmn/README.md +455 -0
  36. package/docs/hr/README.md +455 -0
  37. package/docs/ht/README.md +455 -0
  38. package/docs/hu/README.md +455 -0
  39. package/docs/hy/README.md +455 -0
  40. package/docs/id/README.md +455 -0
  41. package/docs/ig/README.md +455 -0
  42. package/docs/is/README.md +455 -0
  43. package/docs/it/README.md +455 -0
  44. package/docs/iw/README.md +455 -0
  45. package/docs/ja/README.md +455 -0
  46. package/docs/jv/README.md +455 -0
  47. package/docs/ka/README.md +455 -0
  48. package/docs/kk/README.md +455 -0
  49. package/docs/km/README.md +455 -0
  50. package/docs/kn/README.md +455 -0
  51. package/docs/ko/README.md +455 -0
  52. package/docs/ku/README.md +455 -0
  53. package/docs/ky/README.md +455 -0
  54. package/docs/la/README.md +455 -0
  55. package/docs/lb/README.md +455 -0
  56. package/docs/lo/README.md +455 -0
  57. package/docs/lt/README.md +455 -0
  58. package/docs/lv/README.md +455 -0
  59. package/docs/mg/README.md +455 -0
  60. package/docs/mi/README.md +455 -0
  61. package/docs/mk/README.md +455 -0
  62. package/docs/ml/README.md +455 -0
  63. package/docs/mn/README.md +455 -0
  64. package/docs/mr/README.md +455 -0
  65. package/docs/ms/README.md +455 -0
  66. package/docs/mt/README.md +455 -0
  67. package/docs/my/README.md +455 -0
  68. package/docs/ne/README.md +455 -0
  69. package/docs/nl/README.md +455 -0
  70. package/docs/no/README.md +455 -0
  71. package/docs/ny/README.md +455 -0
  72. package/docs/or/README.md +455 -0
  73. package/docs/pa/README.md +455 -0
  74. package/docs/pl/README.md +455 -0
  75. package/docs/ps/README.md +455 -0
  76. package/docs/pt/README.md +455 -0
  77. package/docs/ro/README.md +455 -0
  78. package/docs/ru/README.md +455 -0
  79. package/docs/rw/README.md +455 -0
  80. package/docs/sd/README.md +455 -0
  81. package/docs/si/README.md +455 -0
  82. package/docs/sk/README.md +455 -0
  83. package/docs/sl/README.md +455 -0
  84. package/docs/sm/README.md +455 -0
  85. package/docs/sn/README.md +455 -0
  86. package/docs/so/README.md +455 -0
  87. package/docs/sq/README.md +455 -0
  88. package/docs/sr/README.md +455 -0
  89. package/docs/st/README.md +455 -0
  90. package/docs/su/README.md +455 -0
  91. package/docs/sv/README.md +455 -0
  92. package/docs/sw/README.md +455 -0
  93. package/docs/ta/README.md +455 -0
  94. package/docs/te/README.md +455 -0
  95. package/docs/tg/README.md +455 -0
  96. package/docs/th/README.md +455 -0
  97. package/docs/tk/README.md +455 -0
  98. package/docs/tl/README.md +455 -0
  99. package/docs/tr/README.md +455 -0
  100. package/docs/tt/README.md +455 -0
  101. package/docs/ug/README.md +455 -0
  102. package/docs/uk/README.md +455 -0
  103. package/docs/ur/README.md +455 -0
  104. package/docs/uz/README.md +455 -0
  105. package/docs/vi/README.md +455 -0
  106. package/docs/xh/README.md +455 -0
  107. package/docs/yi/README.md +455 -0
  108. package/docs/yo/README.md +455 -0
  109. package/docs/zh/README.md +455 -0
  110. package/docs/zu/README.md +455 -0
  111. package/drivers/b2/index.js +24 -6
  112. package/hokey.json +16 -0
  113. package/index.js +33 -17
  114. package/package.json +3 -2
  115. package/test/api.spec.js +319 -306
  116. package/util/logger.js +1 -1
  117. package/util/redis.js +1 -1
@@ -0,0 +1,455 @@
1
+ Mobiletto
2
+ =========
3
+
4
+ Ko Mobiletto he paparanga tangohanga rokiroki JavaScript, me te whakamunatanga taha-kiritaki marama.
5
+
6
+ # Ihirangi
7
+ * [He aha a Mobiletto?](#He aha-Mobiletto?)
8
+ * [Tīmatatanga tere](#Tīmata-tere)
9
+ * [Mobiletto CLI](#mobiletto-cli)
10
+ * [Putake](#Source)
11
+ * [Whakamahinga Taketake](#Whakamahinga Taketake)
12
+ * [Metadata](#Metadata)
13
+ * [Kāhua kawemai kē](#Alternate-import-style)
14
+ * [Keteroki](#Keteroki)
15
+ * [Whakaata](#Whakaata)
16
+ * [Whakamunatanga Puata](#Whakamunatanga Puata)
17
+ * [Te hurihanga matua](#Key-huringa)
18
+ * [Atanga atekōkiri](#Atanga Atekōkiri)
19
+ * [Takitaki](#Takitaki)
20
+
21
+ # Panuitia tenei ki tetahi atu reo
22
+ Kua whakamaoritia tenei tuhinga README.md, ma te [hokeylization](https://github.com/cobbzilla/hokeylization), ki roto
23
+ **[nga reo katoa e tautokohia ana e Google Translate](https://cloud.google.com/translate/docs/languages)!**
24
+
25
+ E mohio ana ahau ehara i te mea tino tika, engari ko taku tumanako he pai ake i te kore!
26
+
27
+ [🇸🇦 Arapi](../ar/README.md)
28
+ [🇧🇩 Bengali](../bn/README.md)
29
+ [🇩🇪 Tiamana](../de/README.md)
30
+ [🇺🇸 Ingarihi](../en/README.md)
31
+ [🇪🇸 Paniora](../es/README.md)
32
+ [🇫🇷 Wīwī](../fr/README.md)
33
+ [🇹🇩 Hausa](../ha/README.md)
34
+ [🇮🇳 Hindi](../hi/README.md)
35
+ [🇮🇩 Indonesian](../id/README.md)
36
+ [🇮🇹 Itari](../it/README.md)
37
+ [🇯🇵 Japanese](../ja/README.md)
38
+ [🇰🇷 Korean](../ko/README.md)
39
+ [🇮🇳 Maranthi](../mr/README.md)
40
+ [🇵🇱 Polish](../pl/README.md)
41
+ [🇧🇷 Potiti](../pt/README.md)
42
+ [🇷🇺 Ruhia](../ru/README.md)
43
+ [🇰🇪 Swahili](../sw/README.md)
44
+ [🇵🇭 Tagalog](../tl/README.md)
45
+ [🇹🇷 Turkish](../tr/README.md)
46
+ [🇵🇰 Urdu](../ur/README.md)
47
+ [🇻🇳 Vietnamese](../vi/README.md)
48
+ [🇨🇳 Hainamana](../zh/README.md)
49
+
50
+
51
+ **[📚 ... Nga Reo Katoa ...](../README.md)**
52
+ ----
53
+
54
+ ### He raru kei tenei whakamaoritanga o te README?
55
+ Ko tenei whakamaoritanga o te [README] taketake(https://github.com/cobbzilla/mobiletto/blob/master/README.md)
56
+ kei te he -- *e tino manakohia nga whakatikatika!* Tukuna mai he [tono toia ki a GitHub](https://github.com/cobbzilla/mobiletto/pulls),
57
+ ki te kore koe e pai ki te mahi i tera, [whakatuwhera i tetahi take](https://github.com/cobbzilla/mobiletto/issues)
58
+
59
+ Ina hanga e koe he take GitHub hou mo te whakamaoritanga, mahia:
60
+ * whakauruhia te URL wharangi (kape/whakapiri mai i te pae wahitau tirotiro)
61
+ * whakaurua te tuhinga tika e he ana (tārua/whakapiri mai i te kaitirotiro)
62
+ * whakaahuatia mai he aha te he -- kei te he te whakamaoritanga? kua pakaru te whakatakotoranga?
63
+ * tuku mai he whakaaro mo te whakamaoritanga pai ake, me pehea ranei te whakatakotoranga tika o te tuhinga
64
+ * **Mauruuru!**
65
+
66
+ ## He aha a Mobiletto?
67
+
68
+ ### Kia ora te kaihoko maukati!
69
+ Ko nga momo kaiwhakarato rokiroki kapua he API hotokore. Ahakoa te hunga e ngana ana mo te "hototahi S3"
70
+ he whanonga motuhake.
71
+
72
+ Ina whiriwhiria e koe tetahi kaihoko rokiroki mo to taupānga, mena ka tohu tika koe ki to API, to taupānga
73
+ kei te whakawhirinaki inaianei ki tera ratonga. Ka haere te wa, ka whakaemihia te waehere, ka huri nga kaihoko
74
+ e kore e taea. Nau mai ki te ao ngahau o te raka kaihoko!
75
+
76
+ I hangaia a Mobiletto ki te whakaoti i tenei raru. Ma te whakawaehere i to taupānga ki te API a mobiletto, ka taea e koe
77
+ Hurihia nga kaiwhakarato rokiroki me te mohio ka rite te ahua o te paparanga rokiroki o to taupānga.
78
+
79
+ ### He whakamatautau nui
80
+ Ka whakamatautauhia nga taraiwa katoa mo te whanonga rite me te 60+ whakamatautau mo ia taraiwa.
81
+ Ka whakamatauhia e matou nga taraiwa katoa me nga huinga katoa o:
82
+ * Whakamuna: kua whakahohea me te mono
83
+ * Redis cache: kua whakahohea me te mono
84
+
85
+ Ma tenei huarahi ka mau te rongo ki a maatau ka rite tonu te mahi a mobiletto ahakoa ko wai te taraiwa e whakamahia ana e koe,
86
+ ahakoa ka taea e koe te keteroki me te whakamunatanga/ranei.
87
+
88
+ ### Tautoko taraiwa
89
+ Nga taraiwa rokiroki Mobiletto o naianei:
90
+ * `s3` : Amazon S3
91
+ * `b2` : Backblaze B2
92
+ * `local` : pūnaha kōnae ā-rohe
93
+
94
+ *Ko nga takoha hei tautoko i te maha atu o nga kaiwhakarato rokiroki kapua e tino manakohia ana!*
95
+
96
+ ## mobiletto-cli
97
+ Ko te Mobiletto ka whakamahia hei whare pukapuka e etahi atu waehere JavaScript.
98
+
99
+ Hei mahi me te mobiletto i te raina whakahau, whakamahia [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)
100
+
101
+ ## Puna
102
+ * [mobiletto i runga i GitHub](https://github.com/cobbzilla/mobiletto)
103
+ * [mobiletto on npm](https://www.npmjs.com/package/mobiletto)
104
+
105
+ ## Tīmata Tere
106
+ He tauira poto ma te whakamahi i te taraiwa mobiletto `s3` .
107
+
108
+ He rite tonu te mahi o tenei waehere mena he `b2`, he `b2` ranei te `local` .
109
+
110
+ const storage = require('mobiletto')
111
+ const bucket = await storage.connect('s3', aws_key, aws_secret, {bucket: 'bk'})
112
+
113
+ // list objects: returns array of metadata objects
114
+ const listing = await bucket.list()
115
+ const dirList = await bucket.list('some/dir/')
116
+ const everything = await bucket.list('', {recursive: true})
117
+
118
+ // write an entire file
119
+ let bytesWritten = await bucket.writeFile('some/path', someBufferOfData)
120
+
121
+ // write a file from a stream/generator
122
+ bytesWritten = await bucket.write('some/path', streamOrGenerator)
123
+
124
+ // read an entire file
125
+ // returns null if an exception would otherwise be thrown
126
+ const bufferOrNull = await bucket.safeReadFile('some/path')
127
+
128
+ // stream-read a file, passing data to callback
129
+ const bytesRead = await bucket.read('some/path', (chunk) => { ...do something with chunk... } )
130
+
131
+ // remove a file, returns the path removed
132
+ let removed = await bucket.remove('some/path') // removed is a string
133
+
134
+ // remove a directory, returns array of paths removed
135
+ removed = await bucket.remove('some/directory', {recursive: true}) // removed is now an array!
136
+
137
+ ----
138
+ ## Whakamahinga taketake
139
+ He tauira tino whanui ake, e whakaatu ana i te nuinga o nga ahuatanga e tukuna ana:
140
+
141
+ const { mobiletto } = require('mobiletto')
142
+
143
+ // General usage
144
+ const api = await mobiletto(driverName, key, secret, opts)
145
+
146
+ // To use 'local' driver:
147
+ // * key: base directory
148
+ // * secret: ignored, can be null
149
+ // * opts object:
150
+ // * readOnly: optional, never change anything on the filesystem; default is false
151
+ // * fileMode: optional, permissions used when creating new files, default is 0600. can be string or integer
152
+ // * dirMode: optional, permissions used when creating new directories, default is 0700. can be string or integer
153
+ const local = await mobiletto('local', '/home/ubuntu/tmp', null, {fileMode: 0o0600, dirMode: '0700'})
154
+
155
+ // To use 's3' driver:
156
+ // * key: AWS Access Key ID
157
+ // * secret: AWS Secret Key
158
+ // * opts object:
159
+ // * readOnly: optional, never change anything on the bucket; default is false
160
+ // * bucket: required, name of the S3 bucket
161
+ // * region: optional, the AWS region to communicate with, default is us-east-1
162
+ // * prefix: optional, all read/writes within the S3 bucket will be under this prefix
163
+ // * delimiter: optional, directory delimiter, default is '/' (note: always '/' when encryption is enabled)
164
+ const s3 = await mobiletto('s3', aws_key, aws_secret, {bucket: 'bk', region: 'us-east-1'})
165
+
166
+ // To use 'b2' driver:
167
+ // * key: Backblaze Key ID
168
+ // * secret: Backblaze Application Key
169
+ // * opts object:
170
+ // * readOnly: optional, never change anything on the bucket; default is false
171
+ // * bucket: required, the ID (**not the name**) of the B2 bucket
172
+ // * prefix: optional, all read/writes within the B2 bucket will be under this prefix
173
+ // * delimiter: optional, directory delimiter, default is '/' (note: always '/' when encryption is enabled)
174
+ // * partSize: optional, large files will be split into chunks of this size when uploading
175
+ const b3 = await mobiletto('b2', b2_key_id, b2_app_key, {bucket: 'bk', partSize: 10000000})
176
+
177
+ // List files
178
+ api.list() // --> returns an array of metadata objects
179
+
180
+ // List files recursively
181
+ api.list({ recursive: true })
182
+
183
+ // List files in a directory
184
+ const path = 'some/path'
185
+ api.list(path)
186
+ api.list(path, { recursive: true }) // also supports recursive flag
187
+
188
+ // Visit files in a directory -- visitor function must be async
189
+ api.list(path, { visitor: myAsyncFunc })
190
+ api.list(path, { visitor: myAsyncFunc, recursive: true })
191
+
192
+ // The `list` method throws MobilettoNotFoundError if the path does not exist
193
+ // When you call `safeList` on a non-existent path, it returns an empty array
194
+ api.safeList('/path/that/does/not/exist') // returns []
195
+
196
+ // Read metadata for a file
197
+ api.metadata(path) // returns metadata object
198
+
199
+ // The `metadata` method throws MobilettoNotFoundError if the path does not exist
200
+ // When you call `safeMetadata` on a non-existent path, it returns null
201
+ api.safeMetadata('/tmp/does_not_exist') // returns null
202
+
203
+ // Read a file
204
+ // Provide a callback that writes the data someplace
205
+ const callback = (chunk) => { ... write chunk somewhere ... }
206
+ api.read(path, callback) // returns count of bytes read
207
+
208
+ // Read an entire file at once
209
+ const data = await api.readFile(path) // returns a byte Buffer of the file contents
210
+
211
+ // Read an entire file at once
212
+ // returns null if an exception would otherwise be thrown
213
+ const bufferOrNull = await bucket.safeReadFile('some/path')
214
+
215
+ // Write a file
216
+ // Provide a generator function that yields chunks of data
217
+ const generator = function* () {
218
+ while ( ... more-data-to-return ... ) {
219
+ data = ... load-data ...
220
+ yield data
221
+ }
222
+ }
223
+ local.api(path, generator) // returns count of bytes written
224
+
225
+ // Write an entire file at once (convenience method)
226
+ await api.writeFile(path, bufferOrString) // returns count of bytes written
227
+
228
+ // Delete a file
229
+ // Quiet param is optional (default false), when set errors will not be thrown if the path does not exist
230
+ // Always returns a value or throws an error.
231
+ // Return value may be a single string of the file removed, or an array of all files removed (driver-dependent)
232
+ const quiet = true
233
+ api.remove(path, {quiet}) // returns single path removed
234
+
235
+ // Recursively delete a directory and do it quietly (do not report errors)
236
+ const recursive = true
237
+ const quiet = true
238
+ api.remove(path, {recursive, quiet}) // returns array of paths removed
239
+
240
+ ## Raraunga meta
241
+ Ko te tono `metadata` he whakahoki metadata mo te whakaurunga punaha konae kotahi.
242
+ Waihoki, ko te uara whakahoki mai i te tono `list` he huinga ahanoa metadata.
243
+
244
+ He penei te ahua o te ahanoa metadata:
245
+
246
+ {
247
+ "name": "fully/qualified/path/to/file",
248
+ "type": "entry-type",
249
+ "size": size-in-bytes,
250
+ "ctime": creation-time-epoch-millis,
251
+ "mtime": modification-time-epoch-millis
252
+ }
253
+
254
+ Ko te āhuatanga `type` ka taea te `file` , `dir` , `link` , te `special` ranei.
255
+
256
+ I runga i te momo atekōkiri, karekau pea te tono `list` e whakahoki āpure katoa. Ko te `name` ' me `type` āhuatanga
257
+ me noho tonu. Ma te tono `metadata` ka whakahoki mai i nga taonga katoa e waatea ana.
258
+
259
+ ## Kāhua kawemai kē
260
+ Kawemai i te kōwae hōkai-katoa ka whakamahi i te mahi `connect` :
261
+
262
+ const storage = require('mobiletto')
263
+ const opts = {bucket: 'bk', region: 'us-east-1'}
264
+ const s3 = await storage.connect('s3', aws_key, aws_secret, opts)
265
+ const objectData = await s3.readFile('some/path')
266
+
267
+ ## Keteroki
268
+ He pai ake te mahi a Mobiletto me te keteroki <a href="https://redis.io">redis</a> .
269
+
270
+ Ka ngana a Mobiletto ki te hono atu ki tetahi tauira redis i te 127.0.0.1:6379
271
+
272
+ Ka taea e koe te whakakore i tetahi o enei:
273
+ * Tautuhia te `MOBILETTO_REDIS_HOST` env var, mobiletto hono ki konei hei utu mo te localhost
274
+ * Tautuhia te `MOBILETTO_REDIS_PORT` env var, ka whakamahia tenei tauranga
275
+
276
+ Ka rokirokia e Mobiletto ana taviri redis katoa me te prefix `_mobiletto__` . Ka taea e koe te huri i tenei
277
+ mā te tautuhi i te `MOBILETTO_REDIS_PREFIX` env var.
278
+
279
+ Ka taea hoki te whakarite keteroki hononga-hononga me te ahanoa `opts.redisConfig` :
280
+
281
+ const redisConfig = {
282
+ enabled: true, // optional, default is true. if false other props are ignored
283
+ host: '127.0.0.1',
284
+ port: 6379,
285
+ prefix: '_mobiletto__'
286
+ }
287
+ const opts = { redisConfig, bucket: 'bk', region: 'us-east-1' }
288
+ const s3 = await storage.connect('s3', aws_key, aws_secret, opts)
289
+
290
+ ### Kaore koe e hiahia ki te keteroki redis?
291
+ Hei mono: tukuna `enabled: false` ki to ahanoa `opts.redisConfig` ina whakau koe i to hononga.
292
+
293
+ Ka rite ki te korero i raro nei, ko te whakakore i te keteroki ka pa he kino ki te mahi me te nui ake o nga tono
294
+ ki te rokiroki e tino hiahia ana koe.
295
+
296
+ ### Arataki keteroki
297
+ **Pupuri whakamuna**: te panui/tuhi he puhoi ake te putunga whakamuna i te tikanga,
298
+ engari ko te whakatere huri noa i nga raarangi (he mahi etahi) he tino utu. Te whakamahi i te keteroki redis
299
+ ka hoatu e koe he whakanui mahi nui.
300
+
301
+ He haumaru te keteroki taunoa, engari kare e pai ana mena he maha nga mahi tuhi/tango.
302
+ Ko nga mahi tuhi, tango ranei ka whakakore i te keteroki katoa, me te whakarite ka kite nga panui ka whai ake
303
+ huringa hou.
304
+
305
+ ### taputapu CLI
306
+ Mena kei te whakamahi koe i tetahi taputapu CLI penei i a [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
307
+ Ka tino hiahia koe kia whakahohea te keteroki redis, na te mea ka mau tonu i nga tono o te whakahau `mo` .
308
+
309
+ ## Whakaata
310
+
311
+ // Copy a local filesystem mobiletto to S3
312
+ s3.mirror(local)
313
+
314
+ // Mirror a local subdirectory from one mobiletto to an S3 mobiletto, with it's own subdirectory
315
+ local.mirror(s3, 'some/local-folder', 'some/s3-folder')
316
+
317
+ Ko te whakahau `mirror` he mahi kape kotahi-wa o nga konae katoa mai i tetahi waea pūkoro ki tetahi atu.
318
+ Karekau he tukanga hei pupuri i te whakaata i roto i te waa. Whakahaerehia ano te tono `mirror`
319
+ ki te tukutahi i nga konae ngaro.
320
+
321
+ Ko te uara whakahoki mai i `mirror` ' he ahanoa ngawari me nga porotiti mo te maha o nga konae i angitu
322
+ i whakaatahia me te maha o nga konae i hapa:
323
+
324
+ {
325
+ success: count-of-files-mirrored,
326
+ errors: count-of-files-with-errors
327
+ }
328
+
329
+ WHAKATŪPATO: Ko te whakaata i nga huinga raraunga nui ka pau te waa me te whakapau kaha
330
+
331
+ Ki te `mirror` karanga semantics i etahi wa ka raruraru te mohio ko wai te
332
+ te kaipānui me wai te kaituhi. Whakaarohia he korero taumahi: te "maui-maui mobiletto"
333
+ Ko te mea kua tautapahia ki te (raraunga whakaata kua tuhia), me te "mobiletto matau" (te
334
+ tohenga ki te tikanga `mirror` ) ko te uara e tautapa ana (ka panuitia nga raraunga whakaata).
335
+
336
+ ## Whakamunatanga marama
337
+ Whakahohea te whakamunatanga taha-kiritaki marama:
338
+
339
+ // Pass encryption parameters
340
+ const encryption = {
341
+ // key is required, must be >= 16 chars
342
+ key: randomstring.generate(128),
343
+
344
+ // optional, the default is to derive IV from key
345
+ // when set, IV must be >= 16 chars
346
+ iv: randomstring.generate(128),
347
+
348
+ // optional, the default is aes-256-cbc
349
+ algo: 'aes-256-cbc'
350
+ }
351
+ const api = await mobiletto(driverName, key, secret, opts, encryption)
352
+
353
+ // Subsequent write operations will encrypt data (client side) when writing
354
+ // Subsequent read operations will decrypt data (client side) when reading
355
+
356
+ Kei te aha? He whaiaronga "whakaurunga whaiaronga" (rere) motuhake (whakamuna) e whai ana he aha nga konae kei roto
357
+ whaiaronga (aka te whaiaronga whaiaro).
358
+ * Ko te tono `list` ka panui i nga konae whakaurunga whaiaronga, ka wetemuna ia ara kua whakarārangitia; ka whakahoki metadata mo ia kōnae
359
+ * Ko nga tono `list` he koretake ake, ina koa mo nga whaiaronga he maha nga konae
360
+ * Ko te tono `write` he tuhi i nga konae rereke ki roto i te raarangi whaiaronga o ia matua, he recursively; ka tuhia te kōnae
361
+ * Ko nga tono `write` ka puta he O(N) tuhi, me te N = te hohonu i roto i te rarangi whaiaronga.
362
+ * Ko te tono `remove` ka tango i te konae dirent e rite ana, me tona matua ki te putua, ka hoki whakamuri; ka tango i te konae
363
+ * Ko nga tono `remove` -kore ka puta te O(N) panui me te maha o nga mukunga, me te N = te hohonu i roto i te raarangi whaiaronga.
364
+ * He utu nui nga whakahau `remove` i runga i nga punaha konae nui me te hohonu
365
+
366
+ Kia mahara ahakoa kua whakahohea te whakamunatanga taha-kiritaki, he hoa riri e tino kitea ana ki to taha-tumau whakamuna.
367
+ te rokiroki, ahakoa kaore he ki, ka taea tonu te kite i te tapeke o nga raarangi whaiaronga me te maha o nga konae kei roto i ia waahanga, me era atu
368
+ kia kaha, kimihia etahi, te katoa ranei o te hanganga katoa o te rarangi whaiaronga.
369
+ *Tuhipoka: Whakamahia he hanganga ahua papatahi kia pai ake te haumarutanga.*
370
+ Kare te hoa riri e mohio ki nga ingoa o nga raarangi me nga konae mena ka mohio ano ratou ki to whakamunatanga
371
+ kī, i momoho rānei te whakamunatanga. Ka mutu nga peti katoa!
372
+
373
+ ### Mahinga me te keteroki
374
+ Ko nga mahi i runga i te rokiroki whakamunatia ka puhoi. Ko nga rarangi recursive me nga tangohanga ka tino puhoi.
375
+ He nui te awhina o te keteroki ma te redis, engari kia mohio kei te peehia te keteroki ki runga i nga tuhi ka tangohia ranei.
376
+
377
+ ## Te hurihanga matua
378
+ Waihangatia he waea pūkoro me to taviri hou, ka whakaatahia nga raraunga tawhito ki roto:
379
+
380
+ const storage = require('mobiletto')
381
+
382
+ const oldEncryption = { key: .... }
383
+ const oldStorage = await storage.connect('s3', aws_key, aws_secret, {bucket: 'bk', region: 'us-east-1'}, oldEncryption)
384
+
385
+ const newEncryption = { key: .... }
386
+ const newStorage = await storage.connect('s3', aws_key, aws_secret, {bucket: 'zz', region: 'us-east-1'}, newEncryption)
387
+
388
+ newStorage.mirror(oldStorage) // if oldStorage is very large, this may take a looooooong time...
389
+
390
+ ## Atanga taraiwa
391
+ Ko te taraiwa he konae JS ka kaweake i te mahi 'storageClient' me tenei waitohu:
392
+
393
+ function storageClient (key, secret, opts)
394
+
395
+ * `key` : he aho, ko to API matua (mo te atekōkiri `local` koinei te whaiaronga turanga)
396
+ * `secret` : he aho, to API ngaro (ka taea te waiho mo te taraiwa `local` )
397
+ * `opts` : he ahanoa, ko ngā āhuatanga mō ia atekōkiri:
398
+ * Mo te `local` , ma nga `fileMode` me te `dirMode` e whakatau me pehea te hanga i nga konae hanga hou me nga whaiaronga.
399
+ * Mo `s3` , me hiahia te taonga `bucket` . Ko nga ahuatanga whiriwhiri ko:
400
+ * `region`: the S3 region, default is us-east-1
401
+ * `prefix`: a prefix to prepend to all S3 paths, default is the empty string
402
+ * `delimiter`: the directory delimiter, default is '/'
403
+
404
+ Ko te ahanoa ka whakahokia mai e te mahi storageClient me tautuhi enei mahi:
405
+
406
+ // Test the driver before using, ensure proper configuration
407
+ async testConfig ()
408
+
409
+ // List files in path (or from base-directory)
410
+ // If recursive is true, list recursively
411
+ // If visitor is defined, it will be an async function. await the visitor function on each file found
412
+ // Otherwise, perform the listing and return an array of objects
413
+ async list (path, recursive = false, visitor = null) // path may be omitted
414
+
415
+ // Read metadata for a path
416
+ async metadata (path)
417
+
418
+ // Read a file
419
+ // callback receives a chunk of data. endCallback is called at end-of-stream
420
+ async read (path, callback, endCallback = null)
421
+
422
+ // Write a file
423
+ // driver must be able to handle a generator or a stream
424
+ async write (path, generatorOrReadableStream)
425
+
426
+ // Remove a file, or recursively delete a directory
427
+ // returns a string of a single path removed, or an array of multiple paths removed
428
+ async remove (path, recursive = false, quiet = false)
429
+
430
+ ## Takitaki
431
+ Ka whakamahi a Mobiletto i te whare pukapuka takiuru [winston](https://www.npmjs.com/package/winston).
432
+
433
+ Kei roto i nga rangitaki ** nga ara konae me nga karere hapa, engari ka **kaore e mau nga taviri, nga mea ngaro,
434
+ etahi atu korero whirihoranga hononga ranei.
435
+
436
+ ### Taumata rangitaki
437
+ Whakamahia te taurangi taiao `MOBILETTO_LOG_LEVEL` ki te tautuhi i te taumata rangitaki, ma te whakamahi i tetahi
438
+ o nga taumata `npm` kua tautuhia ki [https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels)
439
+
440
+ Ko te taumata taunoa ko `error` . Ko te taumata tino korero he `silly` , ahakoa he motini i tenei wa
441
+ karekau e takiuru ki nga taumata i raro iho i `debug`
442
+
443
+ MOBILETTO_LOG_LEVEL=silly # maximum logs!
444
+
445
+ ### Kōnae rangitaki
446
+ Ma te taunoa, ka tuhi te kairakau ki te papatohu. Hei tuku rangitaki ki tetahi konae, tautuhia te `MOBILETTO_LOG_FILE`
447
+ taurangi taiao. I te wa e takiuru ana ki tetahi konae, ka kore e tuhia nga raarangi ki te papatohu.
448
+
449
+ MOBILETTO_LOG_FILE=/var/my_mobiletto_log
450
+
451
+ Hei whakaweto i te takiuru:
452
+
453
+ MOBILETTO_LOG_FILE=/dev/null
454
+
455
+ </pre>