mobiletto 1.2.0 → 2.0.0

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 (127) hide show
  1. package/lib/cjs/index.d.ts +2 -0
  2. package/lib/cjs/index.js +30 -0
  3. package/lib/cjs/package.json +16 -0
  4. package/lib/esm/index.d.ts +2 -0
  5. package/lib/esm/index.js +12 -0
  6. package/package.json +27 -13
  7. package/.babelrc +0 -5
  8. package/.eslintrc.js +0 -14
  9. package/docs/README.md +0 -113
  10. package/docs/af/README.md +0 -481
  11. package/docs/am/README.md +0 -481
  12. package/docs/ar/README.md +0 -481
  13. package/docs/az/README.md +0 -481
  14. package/docs/be/README.md +0 -481
  15. package/docs/bg/README.md +0 -481
  16. package/docs/bn/README.md +0 -481
  17. package/docs/bs/README.md +0 -481
  18. package/docs/ca/README.md +0 -481
  19. package/docs/ceb/README.md +0 -481
  20. package/docs/co/README.md +0 -481
  21. package/docs/cs/README.md +0 -481
  22. package/docs/cy/README.md +0 -481
  23. package/docs/da/README.md +0 -481
  24. package/docs/de/README.md +0 -481
  25. package/docs/el/README.md +0 -481
  26. package/docs/eo/README.md +0 -481
  27. package/docs/es/README.md +0 -481
  28. package/docs/et/README.md +0 -481
  29. package/docs/eu/README.md +0 -481
  30. package/docs/fa/README.md +0 -481
  31. package/docs/fi/README.md +0 -481
  32. package/docs/fr/README.md +0 -481
  33. package/docs/fy/README.md +0 -481
  34. package/docs/ga/README.md +0 -481
  35. package/docs/gd/README.md +0 -481
  36. package/docs/gl/README.md +0 -481
  37. package/docs/gu/README.md +0 -481
  38. package/docs/ha/README.md +0 -481
  39. package/docs/haw/README.md +0 -481
  40. package/docs/he/README.md +0 -481
  41. package/docs/hi/README.md +0 -481
  42. package/docs/hmn/README.md +0 -481
  43. package/docs/hr/README.md +0 -481
  44. package/docs/ht/README.md +0 -481
  45. package/docs/hu/README.md +0 -481
  46. package/docs/hy/README.md +0 -481
  47. package/docs/id/README.md +0 -481
  48. package/docs/ig/README.md +0 -481
  49. package/docs/is/README.md +0 -481
  50. package/docs/it/README.md +0 -481
  51. package/docs/iw/README.md +0 -481
  52. package/docs/ja/README.md +0 -481
  53. package/docs/jv/README.md +0 -481
  54. package/docs/ka/README.md +0 -481
  55. package/docs/kk/README.md +0 -481
  56. package/docs/km/README.md +0 -481
  57. package/docs/kn/README.md +0 -481
  58. package/docs/ko/README.md +0 -481
  59. package/docs/ku/README.md +0 -481
  60. package/docs/ky/README.md +0 -481
  61. package/docs/la/README.md +0 -481
  62. package/docs/lb/README.md +0 -481
  63. package/docs/lo/README.md +0 -481
  64. package/docs/lt/README.md +0 -481
  65. package/docs/lv/README.md +0 -481
  66. package/docs/mg/README.md +0 -481
  67. package/docs/mi/README.md +0 -481
  68. package/docs/mk/README.md +0 -481
  69. package/docs/ml/README.md +0 -481
  70. package/docs/mn/README.md +0 -481
  71. package/docs/mr/README.md +0 -481
  72. package/docs/ms/README.md +0 -481
  73. package/docs/mt/README.md +0 -481
  74. package/docs/my/README.md +0 -481
  75. package/docs/ne/README.md +0 -481
  76. package/docs/nl/README.md +0 -481
  77. package/docs/no/README.md +0 -481
  78. package/docs/ny/README.md +0 -481
  79. package/docs/or/README.md +0 -481
  80. package/docs/pa/README.md +0 -481
  81. package/docs/pl/README.md +0 -481
  82. package/docs/ps/README.md +0 -481
  83. package/docs/pt/README.md +0 -481
  84. package/docs/ro/README.md +0 -481
  85. package/docs/ru/README.md +0 -481
  86. package/docs/rw/README.md +0 -481
  87. package/docs/sd/README.md +0 -481
  88. package/docs/si/README.md +0 -481
  89. package/docs/sk/README.md +0 -481
  90. package/docs/sl/README.md +0 -481
  91. package/docs/sm/README.md +0 -481
  92. package/docs/sn/README.md +0 -481
  93. package/docs/so/README.md +0 -481
  94. package/docs/sq/README.md +0 -481
  95. package/docs/sr/README.md +0 -481
  96. package/docs/st/README.md +0 -481
  97. package/docs/su/README.md +0 -481
  98. package/docs/sv/README.md +0 -481
  99. package/docs/sw/README.md +0 -481
  100. package/docs/ta/README.md +0 -481
  101. package/docs/te/README.md +0 -481
  102. package/docs/tg/README.md +0 -481
  103. package/docs/th/README.md +0 -481
  104. package/docs/tk/README.md +0 -481
  105. package/docs/tl/README.md +0 -481
  106. package/docs/tr/README.md +0 -481
  107. package/docs/tt/README.md +0 -481
  108. package/docs/ug/README.md +0 -481
  109. package/docs/uk/README.md +0 -481
  110. package/docs/ur/README.md +0 -481
  111. package/docs/uz/README.md +0 -481
  112. package/docs/vi/README.md +0 -481
  113. package/docs/xh/README.md +0 -481
  114. package/docs/yi/README.md +0 -481
  115. package/docs/yo/README.md +0 -481
  116. package/docs/zh/README.md +0 -481
  117. package/docs/zu/README.md +0 -481
  118. package/drivers/b2/index.js +0 -451
  119. package/drivers/local/index.js +0 -315
  120. package/drivers/s3/index.js +0 -316
  121. package/hokey.json +0 -16
  122. package/index.js +0 -10
  123. package/test/api.spec.js +0 -512
  124. package/test/crypt.spec.js +0 -67
  125. package/util/crypt.js +0 -80
  126. package/util/logger.js +0 -27
  127. package/util/redis.js +0 -233
package/docs/gd/README.md DELETED
@@ -1,481 +0,0 @@
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
- * [Stàladh](#Stàladh)
12
- * [Taic is Maoineachadh](#Taic-is-Maoineachadh)
13
- * [Cleachdadh bunaiteach](#Basic-use)
14
- * [Metadata](#Metadata)
15
- * [Stoidhle in-mhalairt eile](#Alternate-import-style)
16
- * [Tasgadh](#Caching)
17
- * [sgàthan](#sgàthan)
18
- * [Crioptachadh follaiseach](#Transparent-encryption)
19
- * [Cuartachadh iuchrach](# Key-rotation)
20
- * [eadar-aghaidh draibhear](#Driver-interface)
21
- * [Logadh](# Logadh)
22
-
23
- # Leugh seo ann an cànan eile
24
- Chaidh an sgrìobhainn README.md seo eadar-theangachadh, tro [hokeylization](https://github.com/cobbzilla/hokeylization), gu
25
- **[a h-uile cànan le taic bho Google Translate](https://cloud.google.com/translate/docs/languages)!**
26
-
27
- Tha mi cinnteach nach eil e foirfe, ach tha mi an dòchas gu bheil e nas fheàrr na dad!
28
-
29
- [🇸🇦 Arabais](../ar/README.md)
30
- [🇧🇩 Bengali](../bn/README.md)
31
- [🇩🇪 Gearmailtis](../de/README.md)
32
- [🇺🇸 Beurla](../ga/README.md)
33
- [🇪🇸 Spàinntis](../es/README.md)
34
- [🇫🇷 Fraingis](../fr/README.md)
35
- [🇹🇩 Hausa](../ha/README.md)
36
- [🇮🇳 Hindi](../hi/README.md)
37
- [🇮🇩 Indonesian](../id/README.md)
38
- [🇮🇹 Eadailtis](../it/README.md)
39
- [🇯🇵 Seapanais](../ja/README.md)
40
- [🇰🇷 Coirèanais](../ko/README.md)
41
- [🇮🇳 Marathi](../mr/README.md)
42
- [🇵🇱 Pòlainnis](../pl/README.md)
43
- [🇧🇷 Portuguese](../pt/README.md)
44
- [🇷🇺 Ruisis](../ru/README.md)
45
- [🇰🇪 Swahili](../sw/README.md)
46
- [🇵🇭 Tagalog](../tl/README.md)
47
- [🇹🇷 Turcais](../tr/README.md)
48
- [🇵🇰 Urdu](../ur/README.md)
49
- [🇻🇳 Bhietnam](../vi/README.md)
50
- [🇨🇳 Sìnis](../zh/README.md)
51
-
52
-
53
- **[📚 ... a h-uile cànan ...](../README.md)**
54
- ----
55
-
56
- ### A bheil duilgheadas ann leis an eadar-theangachadh seo den README?
57
- An eadar-theangachadh sònraichte seo den fhear thùsail [README](https://github.com/cobbzilla/mobiletto/blob/master/README.md)
58
- 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),
59
- no mura h-eil thu comhfhurtail a’ dèanamh sin, [fosgail cùis](https://github.com/cobbzilla/mobiletto/issues)
60
-
61
- Nuair a chruthaicheas tu cùis GitHub ùr mu eadar-theangachadh, feuch an dèan thu:
62
- * cuir a-steach URL na duilleige (lethbhreac / pasg bho bhàr seòlaidh a’ bhrobhsair)
63
- * cuir a-steach an dearbh theacsa a tha ceàrr (lethbhreac / pasgain bhon bhrobhsair)
64
- * 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?
65
- * thoir gu coibhneil moladh air eadar-theangachadh nas fheàrr, no mar a bu chòir an teacsa a bhith air a chruth ceart
66
- * **Tapadh leat!**
67
-
68
- ## Carson Mobiletto?
69
-
70
- ### Soraidh slàn le glasadh an neach-reic!
71
- Tha APIan neo-fhreagarrach aig na diofar sholaraichean stòraidh sgòthan. Fiù 's an fheadhainn a tha a' strì airson "S3-chòrdalachd"
72
- bi giùlan mì-chinnteach agad.
73
-
74
- 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
75
- a nis an eisimeil na seirbhis sin. Mar a thèid ùine seachad agus còd a’ cruinneachadh, bidh luchd-reic ag atharrachadh
76
- sìor fhàs do-sheachanta. Fàilte gu saoghal spòrsail glasadh reiceadair!
77
-
78
- Chaidh Mobiletto a dhealbhadh gus an duilgheadas seo fhuasgladh. Le bhith a’ còdadh an aplacaid agad gu API mobiletto, faodaidh tu gu furasta
79
- 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.
80
-
81
- ### Deuchainn farsaing
82
- Bithear a’ dèanamh deuchainn air a h-uile draibhear airson giùlan co-ionann le 60+ deuchainn airson gach draibhear.
83
- Bidh sinn a’ dèanamh deuchainn air a h-uile draibhear leis a h-uile measgachadh de:
84
- * Crioptachadh: an dà chuid comasach agus ciorramach
85
- * Redis cache: an dà chuid comasach agus ciorramach
86
-
87
- 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,
88
- agus ge bith a bheil thu a’ comasachadh caching agus/no crioptachadh.
89
-
90
- ### Taic dràibhear
91
- Dràibhearan stòraidh Mobiletto gnàthach:
92
- * `s3` : Amazon S3
93
- * `b2` : Cùl-cinn B2
94
- * `local` ionadail`: siostam faidhle ionadail
95
-
96
- * Tha fàilte mhòr air tabhartasan gus taic a thoirt do bharrachd sholaraichean stòraidh neòil!*
97
-
98
- ## mobiletto-cli
99
- Tha Mobiletto an dùil a bhith air a chleachdadh mar leabharlann le còd JavaScript eile.
100
-
101
- Gus obrachadh le mobiletto aig an loidhne-àithne, cleachd [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)
102
-
103
- ## Stòr
104
- * [mobiletto air GitHub](https://github.com/cobbzilla/mobiletto)
105
- * [mobiletto air npm](https://www.npmjs.com/package/mobiletto)
106
-
107
- ## Taic agus Maoineachadh
108
- Tha mi a’ feuchainn ri bhith nam leasaiche bathar-bog còd fosgailte proifeasanta. Tha mi air a bhith ag obair ann
109
- ann an gnìomhachas bathar-bog airson grunn bhliadhnaichean, tha mi air companaidhean soirbheachail a thòiseachadh agus air an reic ri companaidhean poblach.
110
- O chionn ghoirid chaill mi an obair agam, agus gu dearbh chan eil obair sam bith eile agam
111
-
112
- Mar sin tha mi a’ dol a dh’fheuchainn ri bathar-bog feumail a sgrìobhadh agus faicinn a bheil sin ag obair
113
-
114
- Ma tha e a’ còrdadh riut a bhith a’ cleachdadh a’ bhathar-bog seo, bhithinn fada taingeil airson eadhon an
115
- as lugha [tabhartas mìosail tro Patreon](https://www.patreon.com/cobbzilla)
116
-
117
- *Tapadh leat!*
118
-
119
- ## Stàladh
120
- Stàlaich a’ cleachdadh `npm` no `yarn` . Is dòcha gu bheil thu ag iarraidh an dreach `lite` nach eil a’ toirt a-steach na h-uile
121
- faidhlichean README eadar-theangaichte:
122
-
123
- npm install mobiletto-lite
124
- yarn add mobiletto-lite
125
-
126
- Ma tha thu dha-rìribh ag iarraidh na faidhlichean README anns a h-uile cànan, stàlaich an dreach slàn:
127
-
128
- npm install mobiletto
129
- yarn add mobiletto
130
-
131
- ## Tòiseachadh luath
132
- Eisimpleir ghoirid a’ cleachdadh an draibhear mobiletto `s3` .
133
-
134
- Bhiodh an còd seo a’ ruith mar an ceudna nam b’ e `b2` no `local` an dràibhear.
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
- ## Cleachdadh bunaiteach
165
- Eisimpleir fada nas fharsainge, a’ sealltainn a’ mhòr-chuid de na feartan a thathar a’ tabhann:
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
- Bidh an àithne `metadata` a’ tilleadh meata-dàta mu aon inntrigeadh siostam faidhle.
268
- Mar an ceudna, is e an luach tilleadh bhon àithne `list` sreath de nithean meata-dàta.
269
-
270
- Tha cuspair meata-dàta a’ coimhead mar seo:
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
- Faodaidh an togalach `type` a bhith mar `file` , `dir` , `link` , `special` .
281
-
282
- A rèir an t-seòrsa draibhear, chan fhaod àithne `list` a h-uile raon a thilleadh. Na `name` agus `type`
283
- 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.
284
-
285
- ## Stoidhle in-mhalairt eile
286
- Cuir a-steach am modal làn-sgòp agus cleachd an gnìomh `connect` :
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
- ## Tasgadh
294
- Bidh Mobiletto ag obair as fheàrr le tasgadan <a href="https://redis.io">redis</a> .
295
-
296
- Feuchaidh Mobiletto ri ceangal a dhèanamh ri eisimpleir redis air 127.0.0.1:6379
297
-
298
- Faodaidh tu a dhol thairis air aon de na leanas:
299
- * Suidhich an `MOBILETTO_REDIS_HOST` env var, mobiletto ceangal an seo an àite localhost
300
- * Suidhich an `MOBILETTO_REDIS_PORT` env var, thèid am port seo a chleachdadh
301
-
302
- Stòraidh Mobiletto na h-iuchraichean redis aige gu lèir leis an ro-leasachan `_mobiletto__` . Faodaidh tu seo atharrachadh
303
- le bhith a' suidheachadh an `MOBILETTO_REDIS_PREFIX` env var.
304
-
305
- Faodaidh tu cuideachd tasgadh per-connection a shuidheachadh leis an nì `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
- ### Nach eil thu ag iarraidh tasgadan redis?
317
- Gus a chur à comas: cuir seachad `enabled: false` san nì `opts.redisConfig` agad nuair a stèidhicheas tu do cheangal.
318
-
319
- Mar a chaidh a dheasbad gu h-ìosal, bheir casg air tasgadh droch bhuaidh air coileanadh agus thig barrachd iarrtasan
320
- gu stòradh a dh’ fheumas tu.
321
-
322
- ### Stiùireadh caching
323
- ** Stòradh crioptaichte **: chan eil leughadh / sgrìobhadh stòradh crioptaichte ach beagan nas slaodaiche na an àbhaist,
324
- 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
325
- bheir e àrdachadh coileanaidh cudromach dhut.
326
-
327
- 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.
328
- 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
329
- atharrachaidhean as ùire.
330
-
331
- ### innealan CLI
332
- Ma tha thu a’ cleachdadh inneal CLI mar [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
333
- bidh thu gu cinnteach ag iarraidh gun tèid an tasgadan redis a chomasachadh, oir mairidh e thairis air gairmean an àithne `mo` .
334
-
335
- ## Sgàthan
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
- Bidh an àithne `mirror` a 'dèanamh lethbhreac aon-ùine de na faidhlichean gu lèir bho aon mobiletto gu fear eile.
344
- Chan eil e a 'ruith pròiseas sam bith gus an sgàthan a chumail suas thar ùine. Ruith an àithne `mirror` a-rithist
345
- gus faidhlichean sam bith a tha a dhìth a shioncronachadh.
346
-
347
- Tha an luach tilleadh bho `mirror` na nì sìmplidh le cunntairean airson cia mheud faidhle a bha soirbheachail
348
- mar sgàthan agus cia mheud faidhle anns an robh mearachdan:
349
-
350
- {
351
- success: count-of-files-mirrored,
352
- errors: count-of-files-with-errors
353
- }
354
-
355
- RABHADH: Faodaidh a bhith a’ toirt ùine mhòr agus leud-bann a bhith mar sgàthan air seataichean dàta mòra
356
-
357
- Leis a’ ghairm `mirror` ’ semantics faodaidh e a bhith troimh-a-chèile uaireannan a bhith a’ tuigsinn cò a th’ ann
358
- leughadair agus cò e an sgrìobhadair. Smaoinich air mar aithris sònrachaidh: an “làimhe clì mobiletto”
359
- 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
360
- argamaid ris an dòigh `mirror` ’) an luach a thathar a’ sònrachadh (tha dàta sgàthan air a leughadh).
361
-
362
- ## Crioptachadh follaiseach
363
- Dèan comas air crioptachadh follaiseach taobh teachdaiche:
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
- 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
383
- eòlaire (aka an eòlaire dìreach).
384
- * 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
385
- * Tha òrdughan `list` nas neo-èifeachdach, gu sònraichte airson clàran le àireamh mhòr de fhaidhlichean
386
- * 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
387
- * Bidh òrdughan `write` a’ tighinn gu O(N) a’ sgrìobhadh, le N = doimhneachd ann an rangachd an eòlaire
388
- * 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
389
- * 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
390
- * `remove` òrdughan ‘toirt air falbh’ ath-chuairteach air siostaman faidhle mòr is domhainn a bhith daor
391
-
392
- Thoir an aire, eadhon le crioptachadh taobh teachdaiche air a chomasachadh, nàmhaid le làn fhaicsinneachd a-steach don taobh frithealaiche crioptaichte agad
393
- 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
394
- beagan oidhirp, faigh a-mach cuid de structar iomlan rangachd an eòlaire no a h-uile càil.
395
- * Nòta: Cleachd structar meadhanach rèidh airson tèarainteachd nas fheàrr.*
396
- Cha bhiodh fios aig an nàmhaid air ainmean nan clàran/faidhlichean mura biodh fios aca air do chrioptachadh cuideachd
397
- iuchair no bha e air an crioptachadh a sgàineadh gu soirbheachail. Tha a h-uile geall dheth an uairsin!
398
-
399
- ### Coileanadh agus tasgadan
400
- Faodaidh gnìomhachd air stòradh crioptaichte a bhith slaodach. Faodaidh liostaichean ath-chuairteachaidh agus toirt air falbh a bhith gu math slaodach.
401
- 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.
402
-
403
- ## Cuairteachadh iuchrach
404
- Cruthaich mobiletto leis an iuchair ùr agad, agus an uairsin sgàthan an t-seann dàta a-steach ann:
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
- ## Eadar-aghaidh draibhear
417
- Is e draibhear faidhle JS sam bith a dh’ às-mhalairt gnìomh ‘storageClient’ leis an ainm-sgrìobhte seo:
418
-
419
- function storageClient (key, secret, opts)
420
-
421
- * `key` : sreang, an iuchair API agad (airson an draibhear `local` is e seo am prìomh eòlaire)
422
- * `secret` : sreang, an dìomhair API agad (faodar a bhith air fhàgail a-mach airson an draibhear `local` )
423
- * `opts` ' : nì, tha na feartan per-driver:
424
- * Airson `local` , bidh na `fileMode` agus `dirMode` a’ dearbhadh mar a thèid faidhlichean cruthachaidh agus clàran ùra a chruthachadh
425
- * Airson `s3` , tha feum air an togalach `bucket` . Is e feartan roghainneil:
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
- Feumaidh an nì a thilleas an gnìomh storageClient na gnìomhan seo a mhìneachadh:
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
- ## Logadh
457
- Bidh Mobiletto a’ cleachdadh an leabharlann logaidh [winston](https://www.npmjs.com/package/winston).
458
-
459
- Ann an logaichean ** bidh slighean faidhle agus teachdaireachdan mearachd, ach cha bhith ** gu bràth ** iuchraichean, dìomhaireachdan,
460
- no fiosrachadh rèiteachaidh ceangail sam bith eile.
461
-
462
- ### Ìre an loga
463
- Cleachd caochladair àrainneachd `MOBILETTO_LOG_LEVEL` gus an ìre loga a shuidheachadh, a' cleachdadh aon
464
- 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)
465
-
466
- Is e an ìre bunaiteach `error` . Tha an ìre as gnìomhaiche ‘gòrach’, ged a tha e `silly` an-dràsta
467
- na logadh aig ìrean fo `debug`
468
-
469
- MOBILETTO_LOG_LEVEL=silly # maximum logs!
470
-
471
- ### Faidhle loga
472
- Gu gnàthach, bidh an logger a’ sgrìobhadh chun consol. Gus logaichean a chuir gu faidhle, suidhich am faidhle `MOBILETTO_LOG_FILE`
473
- caochladair àrainneachd. Nuair a logas tu gu faidhle, cha tèid logaichean a sgrìobhadh chun chonsail tuilleadh.
474
-
475
- MOBILETTO_LOG_FILE=/var/my_mobiletto_log
476
-
477
- Gus logadh a chuir dheth:
478
-
479
- MOBILETTO_LOG_FILE=/dev/null
480
-
481
- </pre>