mobiletto 1.1.10 → 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 (116) hide show
  1. package/README.md +48 -0
  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 +7 -2
  114. package/package.json +1 -1
  115. package/test/api.spec.js +12 -9
  116. package/util/redis.js +1 -1
@@ -0,0 +1,455 @@
1
+ gluasadach
2
+ ========
3
+
4
+ Tha Mobiletto na shreath tarraing stòraidh JavaScript, le crioptachadh roghainneil taobh teachdaiche follaiseach.
5
+
6
+ # Susbaint
7
+ * [Carson Mobiletto?](#Carson-Mobiletto?)
8
+ * [Tòiseachadh luath](#Tòiseachadh luath)
9
+ * [Mobiletto CLI](#mobiletto-cli)
10
+ * [Stòr](#Stòr)
11
+ * [Cleachdadh bunaiteach](#Basic-use)
12
+ * [Metadata](#Metadata)
13
+ * [Stoidhle in-mhalairt eile](#Alternate-import-style)
14
+ * [Tasgadh](#Caching)
15
+ * [sgàthan](#sgàthan)
16
+ * [Crioptachadh follaiseach](#Transparent-encryption)
17
+ * [Cuartachadh iuchrach](# Key-rotation)
18
+ * [eadar-aghaidh draibhear](#Driver-interface)
19
+ * [Logadh](# Logadh)
20
+
21
+ # Leugh seo ann an cànan eile
22
+ Chaidh an sgrìobhainn README.md seo eadar-theangachadh, tro [hokeylization](https://github.com/cobbzilla/hokeylization), gu
23
+ **[a h-uile cànan le taic bho Google Translate](https://cloud.google.com/translate/docs/languages)!**
24
+
25
+ Tha mi cinnteach nach eil e foirfe, ach tha mi an dòchas gu bheil e nas fheàrr na dad!
26
+
27
+ [🇸🇦 Arabais](../ar/README.md)
28
+ [🇧🇩 Bengali](../bn/README.md)
29
+ [🇩🇪 Gearmailtis](../de/README.md)
30
+ [🇺🇸 Beurla](../ga/README.md)
31
+ [🇪🇸 Spàinntis](../es/README.md)
32
+ [🇫🇷 Fraingis](../fr/README.md)
33
+ [🇹🇩 Hausa](../ha/README.md)
34
+ [🇮🇳 Hindi](../hi/README.md)
35
+ [🇮🇩 Indonesian](../id/README.md)
36
+ [🇮🇹 Eadailtis](../it/README.md)
37
+ [🇯🇵 Seapanais](../ja/README.md)
38
+ [🇰🇷 Coirèanais](../ko/README.md)
39
+ [🇮🇳 Maranthi](../mr/README.md)
40
+ [🇵🇱 Pòlainnis](../pl/README.md)
41
+ [🇧🇷 Portuguese](../pt/README.md)
42
+ [🇷🇺 Ruisis](../ru/README.md)
43
+ [🇰🇪 Swahili](../sw/README.md)
44
+ [🇵🇭 Tagalog](../tl/README.md)
45
+ [🇹🇷 Turcais](../tr/README.md)
46
+ [🇵🇰 Urdu](../ur/README.md)
47
+ [🇻🇳 Bhietnam](../vi/README.md)
48
+ [🇨🇳 Sìnis](../zh/README.md)
49
+
50
+
51
+ **[📚 ... a h-uile cànan ...](../README.md)**
52
+ ----
53
+
54
+ ### A bheil duilgheadas ann leis an eadar-theangachadh seo den README?
55
+ An eadar-theangachadh sònraichte seo den fhear thùsail [README](https://github.com/cobbzilla/mobiletto/blob/master/README.md)
56
+ faodaidh gu bheil e lochtach -- * tha fàilte mhòr air ceartachaidhean!* Feuch an cuir thu [iarrtas tarraing air GitHub](https://github.com/cobbzilla/mobiletto/pulls),
57
+ no mura h-eil thu comhfhurtail a’ dèanamh sin, [fosgail cùis](https://github.com/cobbzilla/mobiletto/issues)
58
+
59
+ Nuair a chruthaicheas tu cùis GitHub ùr mu eadar-theangachadh, feuch an dèan thu:
60
+ * cuir a-steach URL na duilleige (lethbhreac / pasg bho bhàr seòlaidh a’ bhrobhsair)
61
+ * cuir a-steach an dearbh theacsa a tha ceàrr (lethbhreac / pasgain bhon bhrobhsair)
62
+ * thoir cunntas air dè tha ceàrr -- a bheil an t-eadar-theangachadh ceàrr? A bheil an cruth briste ann an dòigh air choreigin?
63
+ * thoir gu coibhneil moladh air eadar-theangachadh nas fheàrr, no mar a bu chòir an teacsa a bhith air a chruth ceart
64
+ * **Tapadh leat!**
65
+
66
+ ## Carson Mobiletto?
67
+
68
+ ### Soraidh slàn le glasadh an neach-reic!
69
+ Tha APIan neo-fhreagarrach aig na diofar sholaraichean stòraidh sgòthan. Fiù 's an fheadhainn a tha a' strì airson "S3-chòrdalachd"
70
+ bi giùlan mì-chinnteach agad.
71
+
72
+ Nuair a thaghas tu reiceadair stòraidh sònraichte airson an aplacaid agad, ma nì thu còd gu dìreach chun API aca, an aplacaid agad
73
+ a nis an eisimeil na seirbhis sin. Mar a thèid ùine seachad agus còd a’ cruinneachadh, bidh luchd-reic ag atharrachadh
74
+ sìor fhàs do-sheachanta. Fàilte gu saoghal spòrsail glasadh reiceadair!
75
+
76
+ Chaidh Mobiletto a dhealbhadh gus an duilgheadas seo fhuasgladh. Le bhith a’ còdadh an aplacaid agad gu API mobiletto, faodaidh tu gu furasta
77
+ atharraich solaraichean stòraidh agus fios agad gum bi còmhdach stòraidh an aplacaid agad gad ghiùlan fhèin san aon dòigh.
78
+
79
+ ### Deuchainn farsaing
80
+ Bithear a’ dèanamh deuchainn air a h-uile draibhear airson giùlan co-ionann le 60+ deuchainn airson gach draibhear.
81
+ Bidh sinn a’ dèanamh deuchainn air a h-uile draibhear leis a h-uile measgachadh de:
82
+ * Crioptachadh: an dà chuid comasach agus ciorramach
83
+ * Redis cache: an dà chuid comasach agus ciorramach
84
+
85
+ Tha an dòigh-obrach seo a’ toirt dhuinn fois inntinn gum bi mobiletto gad ghiùlan fhèin mar an ceudna ge bith dè an draibhear a chleachdas tu,
86
+ agus ge bith a bheil thu a’ comasachadh caching agus/no crioptachadh.
87
+
88
+ ### Taic dràibhear
89
+ Dràibhearan stòraidh Mobiletto gnàthach:
90
+ * `s3` : Amazon S3
91
+ * `b2` : Cùl-cinn B2
92
+ * `local` ionadail`: siostam faidhle ionadail
93
+
94
+ * Tha fàilte mhòr air tabhartasan gus taic a thoirt do bharrachd sholaraichean stòraidh neòil!*
95
+
96
+ ## mobiletto-cli
97
+ Tha Mobiletto an dùil a bhith air a chleachdadh mar leabharlann le còd JavaScript eile.
98
+
99
+ Gus obrachadh le mobiletto aig an loidhne-àithne, cleachd [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)
100
+
101
+ ## Stòr
102
+ * [mobiletto air GitHub](https://github.com/cobbzilla/mobiletto)
103
+ * [mobiletto air npm](https://www.npmjs.com/package/mobiletto)
104
+
105
+ ## Tòiseachadh luath
106
+ Eisimpleir ghoirid a’ cleachdadh an draibhear mobiletto `s3` .
107
+
108
+ Bhiodh an còd seo a’ ruith mar an ceudna nam b’ e `b2` no `local` an dràibhear.
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
+ ## Cleachdadh bunaiteach
139
+ Eisimpleir fada nas fharsainge, a’ sealltainn a’ mhòr-chuid de na feartan a thathar a’ tabhann:
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
+ ## Metadata
241
+ Bidh an àithne `metadata` a’ tilleadh meata-dàta mu aon inntrigeadh siostam faidhle.
242
+ Mar an ceudna, is e an luach tilleadh bhon àithne `list` sreath de nithean meata-dàta.
243
+
244
+ Tha cuspair meata-dàta a’ coimhead mar seo:
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
+ Faodaidh an togalach `type` a bhith mar `file` , `dir` , `link` , `special` .
255
+
256
+ A rèir an t-seòrsa draibhear, chan fhaod àithne `list` a h-uile raon a thilleadh. Na `name` agus `type`
257
+ bu chòir a bhith an làthair an-còmhnaidh. Tillidh àithne `metadata` às dèidh sin a h-uile seilbh a tha ri fhaighinn.
258
+
259
+ ## Stoidhle in-mhalairt eile
260
+ Cuir a-steach am modal làn-sgòp agus cleachd an gnìomh `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
+ ## Tasgadh
268
+ Bidh Mobiletto ag obair as fheàrr le tasgadan <a href="https://redis.io">redis</a> .
269
+
270
+ Feuchaidh Mobiletto ri ceangal a dhèanamh ri eisimpleir redis air 127.0.0.1:6379
271
+
272
+ Faodaidh tu a dhol thairis air aon de na leanas:
273
+ * Suidhich an `MOBILETTO_REDIS_HOST` env var, mobiletto ceangal an seo an àite localhost
274
+ * Suidhich an `MOBILETTO_REDIS_PORT` env var, thèid am port seo a chleachdadh
275
+
276
+ Stòraidh Mobiletto na h-iuchraichean redis aige gu lèir leis an ro-leasachan `_mobiletto__` . Faodaidh tu seo atharrachadh
277
+ le bhith a' suidheachadh an `MOBILETTO_REDIS_PREFIX` env var.
278
+
279
+ Faodaidh tu cuideachd tasgadh per-connection a shuidheachadh leis an nì `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
+ ### Nach eil thu ag iarraidh tasgadan redis?
291
+ Gus a chur à comas: cuir seachad `enabled: false` san nì `opts.redisConfig` agad nuair a stèidhicheas tu do cheangal.
292
+
293
+ Mar a chaidh a dheasbad gu h-ìosal, bheir casg air tasgadh droch bhuaidh air coileanadh agus thig barrachd iarrtasan
294
+ gu stòradh a dh’ fheumas tu.
295
+
296
+ ### Stiùireadh caching
297
+ ** Stòradh crioptaichte **: chan eil leughadh / sgrìobhadh stòradh crioptaichte ach beagan nas slaodaiche na an àbhaist,
298
+ ach tha e gu math daor a bhith a’ seòladh timcheall chlàran (a bhios cuid de rudan a’ dèanamh). A’ cleachdadh tasgadan redis
299
+ bheir e àrdachadh coileanaidh cudromach dhut.
300
+
301
+ Tha an tasgadan bunaiteach sàbhailte, ach chan eil e a’ coileanadh gu math ma tha tòrr obair sgrìobhaidh / toirt air falbh agad.
302
+ Bidh gnìomhachd sgrìobhaidh no toirt air falbh sam bith a’ dèanamh an tasgadan gu lèir neo-dhligheach, a’ dèanamh cinnteach gum faic leughaidhean às deidh sin an
303
+ atharrachaidhean as ùire.
304
+
305
+ ### innealan CLI
306
+ Ma tha thu a’ cleachdadh inneal CLI mar [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
307
+ bidh thu gu cinnteach ag iarraidh gun tèid an tasgadan redis a chomasachadh, oir mairidh e thairis air gairmean an àithne `mo` .
308
+
309
+ ## Sgàthan
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
+ Bidh an àithne `mirror` a 'dèanamh lethbhreac aon-ùine de na faidhlichean gu lèir bho aon mobiletto gu fear eile.
318
+ Chan eil e a 'ruith pròiseas sam bith gus an sgàthan a chumail suas thar ùine. Ruith an àithne `mirror` a-rithist
319
+ gus faidhlichean sam bith a tha a dhìth a shioncronachadh.
320
+
321
+ Tha an luach tilleadh bho `mirror` na nì sìmplidh le cunntairean airson cia mheud faidhle a bha soirbheachail
322
+ mar sgàthan agus cia mheud faidhle anns an robh mearachdan:
323
+
324
+ {
325
+ success: count-of-files-mirrored,
326
+ errors: count-of-files-with-errors
327
+ }
328
+
329
+ RABHADH: Faodaidh a bhith a’ toirt ùine mhòr agus leud-bann a bhith mar sgàthan air seataichean dàta mòra
330
+
331
+ Leis a’ ghairm `mirror` ’ semantics faodaidh e a bhith troimh-a-chèile uaireannan a bhith a’ tuigsinn cò a th’ ann
332
+ leughadair agus cò e an sgrìobhadair. Smaoinich air mar aithris sònrachaidh: an “làimhe clì mobiletto”
333
+ is e an rud a thathas a’ sònrachadh dha (dàta sgàthan air a sgrìobhadh), agus an “làimh dheis mobiletto” (am
334
+ argamaid ris an dòigh `mirror` ’) an luach a thathar a’ sònrachadh (tha dàta sgàthan air a leughadh).
335
+
336
+ ## Crioptachadh follaiseach
337
+ Dèan comas air crioptachadh follaiseach taobh teachdaiche:
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
+ Dè tha dol? Tha eòlaire “inntrigeadh clàr-iùil” (dìreach) (crioptaichte) air leth a’ cumail sùil air dè na faidhlichean a tha ann
357
+ eòlaire (aka an eòlaire dìreach).
358
+ * Bidh an àithne `list` a’ leughadh na faidhlichean inntrigidh eòlaire, a’ dì-chrioptachadh gach slighe a tha air a liostadh; an uairsin tillidh e meata-dàta airson gach faidhle
359
+ * Tha òrdughan `list` nas neo-èifeachdach, gu sònraichte airson clàran le àireamh mhòr de fhaidhlichean
360
+ * Bidh an àithne `write` sgrìobhaidh` a’ sgrìobhadh faidhlichean dìreach ann an eòlaire dhìomhair gach pàrant, gu ath-chùrsach; an uairsin a’ sgrìobhadh am faidhle
361
+ * Bidh òrdughan `write` a’ tighinn gu O(N) a’ sgrìobhadh, le N = doimhneachd ann an rangachd an eòlaire
362
+ * Bidh an àithne `remove` a’ toirt air falbh am faidhle stiùiridh co-fhreagarrach, agus a phàrant ma tha e falamh, a-rithist; an uairsin thoir air falbh am faidhle
363
+ * Bidh òrdughan ‘toirt air falbh’ neo-ath-chuairteach a’ toirt a-steach `remove` O(N) agus is dòcha uimhir de sguabadh às, le N = doimhneachd ann an rangachd an eòlaire
364
+ * `remove` òrdughan ‘toirt air falbh’ ath-chuairteach air siostaman faidhle mòr is domhainn a bhith daor
365
+
366
+ Thoir an aire, eadhon le crioptachadh taobh teachdaiche air a chomasachadh, nàmhaid le làn fhaicsinneachd a-steach don taobh frithealaiche crioptaichte agad
367
+ faodaidh stòradh, eadhon às aonais an iuchair, fhathast an àireamh iomlan de chlàran fhaicinn agus cia mheud faidhle a tha anns gach fear, agus le
368
+ beagan oidhirp, faigh a-mach cuid de structar iomlan rangachd an eòlaire no a h-uile càil.
369
+ * Nòta: Cleachd structar meadhanach rèidh airson tèarainteachd nas fheàrr.*
370
+ Cha bhiodh fios aig an nàmhaid air ainmean nan clàran/faidhlichean mura biodh fios aca air do chrioptachadh cuideachd
371
+ iuchair no bha e air an crioptachadh a sgàineadh gu soirbheachail. Tha a h-uile geall dheth an uairsin!
372
+
373
+ ### Coileanadh agus tasgadan
374
+ Faodaidh gnìomhachd air stòradh crioptaichte a bhith slaodach. Faodaidh liostaichean ath-chuairteachaidh agus toirt air falbh a bhith gu math slaodach.
375
+ Tha tasgadh tro redis na chuideachadh mòr, ach thoir an aire gu bheil an tasgadan air a sruthadh air sgrìobhadh no toirt air falbh.
376
+
377
+ ## Cuairteachadh iuchrach
378
+ Cruthaich mobiletto leis an iuchair ùr agad, agus an uairsin sgàthan an t-seann dàta a-steach ann:
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
+ ## Eadar-aghaidh draibhear
391
+ Is e draibhear faidhle JS sam bith a dh’ às-mhalairt gnìomh ‘storageClient’ leis an ainm-sgrìobhte seo:
392
+
393
+ function storageClient (key, secret, opts)
394
+
395
+ * `key` : sreang, an iuchair API agad (airson an draibhear `local` is e seo am prìomh eòlaire)
396
+ * `secret` : sreang, an dìomhair API agad (faodar a bhith air fhàgail a-mach airson an draibhear `local` )
397
+ * `opts` ' : nì, tha na feartan per-driver:
398
+ * Airson `local` , bidh na `fileMode` agus `dirMode` a’ dearbhadh mar a thèid faidhlichean cruthachaidh agus clàran ùra a chruthachadh
399
+ * Airson `s3` , tha feum air an togalach `bucket` . Is e feartan roghainneil:
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
+ Feumaidh an nì a thilleas an gnìomh storageClient na gnìomhan seo a mhìneachadh:
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
+ ## Logadh
431
+ Bidh Mobiletto a’ cleachdadh an leabharlann logaidh [winston](https://www.npmjs.com/package/winston).
432
+
433
+ Ann an logaichean ** bidh slighean faidhle agus teachdaireachdan mearachd, ach cha bhith ** gu bràth ** iuchraichean, dìomhaireachdan,
434
+ no fiosrachadh rèiteachaidh ceangail sam bith eile.
435
+
436
+ ### Ìre an loga
437
+ Cleachd caochladair àrainneachd `MOBILETTO_LOG_LEVEL` gus an ìre loga a shuidheachadh, a' cleachdadh aon
438
+ de na h-ìrean `npm` a tha air am mìneachadh ann an [https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels)
439
+
440
+ Is e an ìre bunaiteach `error` . Is e an ìre as `silly` , ged a tha e mobiletto an-dràsta
441
+ na logadh aig ìrean fo `debug`
442
+
443
+ MOBILETTO_LOG_LEVEL=silly # maximum logs!
444
+
445
+ ### Faidhle loga
446
+ Gu gnàthach, bidh an logger a’ sgrìobhadh chun consol. Gus logaichean a chuir gu faidhle, suidhich am faidhle `MOBILETTO_LOG_FILE`
447
+ caochladair àrainneachd. Nuair a logas tu gu faidhle, cha tèid logaichean a sgrìobhadh chun chonsail tuilleadh.
448
+
449
+ MOBILETTO_LOG_FILE=/var/my_mobiletto_log
450
+
451
+ Gus logadh a chuir dheth:
452
+
453
+ MOBILETTO_LOG_FILE=/dev/null
454
+
455
+ </pre>