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/ga/README.md DELETED
@@ -1,481 +0,0 @@
1
- Soghluaiste
2
- ========
3
-
4
- Is ciseal astarraingthe stórála JavaScript é Mobiletto, le criptiúchán trédhearcach roghnach ar thaobh an chliaint.
5
-
6
- # Ábhar
7
- * [Cén fáth Mobiletto?](#Why-Mobiletto?)
8
- * [Tús tapa](#Quick-tús)
9
- * [Mobiletto CLI](#mobiletto-cli)
10
- * [Foinse](#Foinse)
11
- * [Suiteáil](#Suiteáil)
12
- * [Tacaíocht agus Maoiniú](#Tacaíocht-agus-Maoiniú)
13
- * [Úsáid bhunúsach](#Basic-use)
14
- * [Meiteashonraí](# Meiteashonraí)
15
- * [Stíl mhalartach iompórtála](# Malartach-stíl iompórtála)
16
- * [Taisce](#Taisce)
17
- * [Scáthán](#Scáthán)
18
- * [Criptiúchán trédhearcach](#Trédhearcach-criptiú)
19
- * [Eochair-uainíocht](#Eochair-uainíocht)
20
- * [Comhéadan tiománaí](# comhéadan tiománaí)
21
- * [Logáil](#Logáil)
22
-
23
- # Léigh é seo i dteanga eile
24
- Aistríodh an doiciméad README.md seo, trí [hokeylization](https://github.com/cobbzilla/hokeylization), go
25
- **[gach teanga a dtacaíonn Google Translate léi]( https://cloud.google.com/translate/docs/languages)!**
26
-
27
- Tá mé cinnte nach bhfuil sé foirfe, ach tá súil agam go bhfuil sé níos fearr ná rud ar bith!
28
-
29
- [🇸🇦 Araibis](../ar/README.md)
30
- [🇧🇩 Beangáilis](../bn/README.md)
31
- [🇩🇪 Gearmáinis](../de/README.md)
32
- [🇺🇸 Béarla](../ga/README.md)
33
- [🇪🇸 Spáinnis](../es/README.md)
34
- [🇫🇷 Fraincis](../fr/README.md)
35
- [🇹🇩 Hausa](../ha/README.md)
36
- [🇮🇳 Hiondúis](../hi/README.md)
37
- [🇮🇩 Indinéisis](../id/README.md)
38
- [🇮🇹 Iodáilis](../it/README.md)
39
- [🇯🇵 Seapáinis](../ja/README.md)
40
- [🇰🇷 Cóiréis](../ko/README.md)
41
- [🇮🇳 Marathi](../mr/README.md)
42
- [🇵🇱 Polainnis](../pl/README.md)
43
- [🇧🇷 Portaingéilis](../pt/README.md)
44
- [🇷🇺 Rúisis](../ru/README.md)
45
- [🇰🇪 Svahaílis](../sw/README.md)
46
- [🇵🇭 Tagálaigis](../tl/README.md)
47
- [🇹🇷 Tuircis](../tr/README.md)
48
- [🇵🇰 Urdais](../ur/README.md)
49
- [🇻🇳 Vítneamais](../vi/README.md)
50
- [🇨🇳 Sínis](../zh/README.md)
51
-
52
-
53
- **[📚 ... Gach Teanga ...](../README.md)**
54
- ----
55
-
56
- ### An bhfuil fadhb leis an aistriúchán seo ar an README?
57
- An t-aistriúchán áirithe seo ar an mbunleagan [README]( https://github.com/cobbzilla/mobiletto/blob/master/README.md)
58
- seans go bhfuil sé lochtach -- *tá fáilte mhór roimh cheartúcháin!* Seol [iarratas tarraingthe ar GitHub](https://github.com/cobbzilla/mobiletto/pulls), le do thoil.
59
- nó mura bhfuil tú compordach é sin a dhéanamh, [oscail ceist]( https://github.com/cobbzilla/mobiletto/issues)
60
-
61
- Nuair a chruthaíonn tú saincheist nua GitHub faoi aistriúchán, déan:
62
- * cuir isteach URL an leathanaigh (cóipeáil/greamaigh ó bharra seoltaí an bhrabhsálaí)
63
- * cuir isteach an téacs cruinn atá mícheart (cóipeáil/greamaigh ón mbrabhsálaí)
64
- * Déan cur síos le do thoil ar a bhfuil mícheart -- an bhfuil an t-aistriúchán mícheart? an bhfuil an fhormáidiú briste ar bhealach éigin?
65
- * go cineálta moladh a thabhairt faoi aistriúchán níos fearr, nó conas is ceart an téacs a fhormáidiú i gceart
66
- * **Go raibh maith agat!**
67
-
68
- ## Cén fáth Mobiletto?
69
-
70
- ### Slán glasáil isteach an díoltóra!
71
- Tá APIanna neamh-chomhoiriúnacha ag na soláthraithe stórála scamall éagsúla. Fiú amháin iad siúd atá ag iarraidh "comhoiriúnacht S3"
72
- iompraíochtaí uathúla a bheith agat.
73
-
74
- Nuair a roghnaíonn tú díoltóir stórála ar leith do d’aip, má chódaíonn tú go díreach chuig a n-API, d’aip
75
- ag brath ar an tseirbhís sin anois. De réir mar a théann an t-am thart agus an cód ag carnadh, éiríonn díoltóirí ag athrú
76
- ag éirí dochosanta. Fáilte chuig an saol spraoi a bhaineann le glasáil díoltóirí!
77
-
78
- Dearadh Mobiletto chun an fhadhb seo a réiteach. Trí d'aip a chódú chuig API mobiletto, is féidir leat go héasca
79
- athraigh soláthraithe stórála agus bíodh a fhios agat go n-iompróidh ciseal stórála d'aip mar an gcéanna.
80
-
81
- ### Tástáil fhairsing
82
- Déantar tástáil ar gach tiománaí le haghaidh iompraíochta comhionann le 60+ tástáil do gach tiománaí.
83
- Déanaimid tástáil ar gach tiománaí le gach meascán de:
84
- * Criptiú: cumasaithe agus díchumasaithe araon
85
- * Taisce Redis: cumasaithe agus díchumasaithe araon
86
-
87
- Tugann an cur chuige seo suaimhneas intinne dúinn go n-iompróidh mobiletto mar an gcéanna is cuma cén tiománaí a úsáideann tú,
88
- agus is cuma má chumasaíonn tú taisceadh agus/nó criptiú.
89
-
90
- ### Tacaíocht tiománaí
91
- Tiománaithe stórála Mobiletto reatha:
92
- * `s3` : Amazon S3
93
- * `b2` : Cúlbhrat B2
94
- * `local` : córas comhaid áitiúil
95
-
96
- *Tá fáilte mhór roimh ranníocaíochtaí chun tacú le níos mó soláthraithe stórála scamall!*
97
-
98
- ## mobiletto-cli
99
- Tá sé beartaithe Mobiletto a úsáid mar leabharlann le cód JavaScript eile.
100
-
101
- Chun oibriú le mobiletto ag an líne ordaithe, úsáid [mobiletto-cli]( https://www.npmjs.com/package/mobiletto-cli)
102
-
103
- ## Foinse
104
- * [mobiletto ar GitHub]( https://github.com/cobbzilla/mobiletto)
105
- * [mobiletto ar npm]( https://www.npmjs.com/package/mobiletto)
106
-
107
- ## Tacaíocht agus Maoiniú
108
- Tá mé ag iarraidh a bheith i mo fhorbróir bogearraí foinse oscailte gairmiúil. Tá mé ag obair i
109
- an tionscal bogearraí le blianta fada anuas, tá cuideachtaí rathúla tosaithe agam agus dhíol mé iad le cuideachtaí poiblí.
110
- Chaill mé mo phost le déanaí, agus níl aon obair eile ar bun agam i ndáiríre
111
-
112
- Mar sin táim chun iarracht a dhéanamh bogearraí cabhrach a scríobh agus féachaint an n-oibríonn sin
113
-
114
- Má bhaineann tú taitneamh as na bogearraí seo a úsáid, bheinn an-bhuíoch as fiú an
115
- [ranníocaíocht mhíosúil trí Patreon](https://www.patreon.com/cobbzilla)
116
-
117
- *Go raibh maith agat!*
118
-
119
- ## Suiteáil
120
- Suiteáil ag baint úsáide as `npm` nó `yarn` . Is dócha gur mhaith leat an leagan `lite` nach n-áirítear go léir an
121
- comhaid README aistrithe:
122
-
123
- npm install mobiletto-lite
124
- yarn add mobiletto-lite
125
-
126
- Más mian leat na comhaid README i ngach teanga, suiteáil an leagan iomlán:
127
-
128
- npm install mobiletto
129
- yarn add mobiletto
130
-
131
- ## Tús Tapa
132
- Sampla gairid ag baint úsáide as an tiománaí `s3` .
133
-
134
- Rithfeadh an cód seo mar an gcéanna dá mba `b2` nó `local` an tiománaí.
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
- ## Bunúsáid
165
- Sampla i bhfad níos fairsinge, ag taispeáint an chuid is mó de na gnéithe a thairgtear:
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
- ## Meiteashonraí
267
- Tugann an t-ordú `metadata` ar ais maidir le hiontráil chóras comhad amháin.
268
- Ar an gcaoi chéanna, is raon de réada meiteashonraí an luach tuairisceáin ón ordú `list` .
269
-
270
- Breathnaíonn réad meiteashonraí 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
- Is féidir an t-airí `type` a bheith mar `file` , `dir` , `link` , nó `special` .
281
-
282
- Ag brath ar an gcineál tiománaí, ní fhéadfaidh ordú `list` gach réimse a thabhairt ar ais. Na hairíonna `name` agus `type`
283
- chóir a bheith i láthair i gcónaí. Tabharfaidh ordú `metadata` ina dhiaidh sin na hairíonna go léir atá ar fáil ar ais.
284
-
285
- ## Stíl iompórtála mhalartach
286
- Iompórtáil an modúl lánscóip agus úsáid an fheidhm `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
- ## Taisce
294
- Is fearr a oibríonn Mobiletto le taisce <a href="https://redis.io">redis</a> .
295
-
296
- Déanfaidh Mobiletto iarracht ceangal a dhéanamh le heisiamh redis ar 127.0.0.1:6379
297
-
298
- Is féidir leat ceachtar díobh seo a shárú:
299
- * Socraigh an `MOBILETTO_REDIS_HOST` var, mobiletto connect anseo in ionad localhost
300
- * Socraigh an `MOBILETTO_REDIS_PORT` var, úsáidfear an port seo
301
-
302
- Stórálfaidh Mobiletto a chuid eochracha redis go léir leis an réimír `_mobiletto__` . Is féidir leat é seo a athrú
303
- tríd an `MOBILETTO_REDIS_PREFIX` var.
304
-
305
- Is féidir leat taisce in aghaidh an naisc a shocrú freisin leis an réad `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
- ### Níl tú ag iarraidh taisceadh redis?
317
- Chun é a dhíchumasú: pas `enabled: false` i do réad `opts.redisConfig` nuair a bhunaíonn tú do nasc.
318
-
319
- Mar a phléitear thíos, beidh drochthionchar ag baint le taisceadh a dhíchumasú ar fheidhmíocht agus tabhófar tuilleadh iarratas
320
- a stóráil gur gá duit i ndáiríre.
321
-
322
- ### Treoir caching
323
- **Stóráil criptithe**: níl an stóráil chriptithe léitheoireachta/scríofa ach beagán níos moille ná mar is gnách,
324
- ach tá sé costasach go leor dul timpeall ar eolairí (a dhéanann roinnt rudaí). Ag baint úsáide as redis cache
325
- tabharfaidh sé borradh feidhmíochta suntasach duit.
326
-
327
- Tá an taisce réamhshocraithe sábháilte, ach ní fheidhmíonn sé go maith má tá go leor oibríochtaí scríofa/bainte agat.
328
- Déanann aon oibríocht scríofa nó bain an taisce iomlán neamhbhailí, ag cinntiú go bhfeicfidh léamha ina dhiaidh sin an taisce
329
- athruithe is déanaí.
330
-
331
- ### uirlisí CLI
332
- Má tá uirlis CLI in úsáid agat mar [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
333
- Is cinnte go mbeidh tú ag iarraidh go mbeidh an taisce redis cumasaithe, mar go maireann sé trasna agairt an ordú `mo` .
334
-
335
- ##Scáthánú
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
- Feidhmíonn an t-ordú `mirror` cóip aonuaire de na comhaid go léir ó mobileto amháin go ceann eile.
344
- Ní reáchtálann sé aon phróiseas chun an scáthán a chothabháil le himeacht ama. Rith an t-ordú `mirror` arís
345
- chun aon chomhaid atá in easnamh a shioncronú.
346
-
347
- Is réad simplí é an luach aischuir ó `mirror` le cuntair le haghaidh cé mhéad comhad a d'éirigh leo
348
- léirithe agus cé mhéad comhad a raibh earráidí ann:
349
-
350
- {
351
- success: count-of-files-mirrored,
352
- errors: count-of-files-with-errors
353
- }
354
-
355
- RABHADH: Féadann sé go leor ama agus bandaleithead a bheith ag baint le scáthánú tacair shonraí mhóra
356
-
357
- Leis an nglao shéimeantach `mirror` sé mearbhall a chur uaireanta a thuiscint cé hé an
358
- léitheoir agus cé hé an scríbhneoir. Samhlaigh go bhfuil sé cosúil le ráiteas sannacháin: an "soghluaistetto láimhe clé"
359
- an rud atá á shannadh do (sonraí scáthaithe scríofa), agus an “soghluaistetto láimhe deise” (an
360
- argóint leis an modh `mirror` ) an luach atá á sannadh (léamh sonraí scáthánaithe).
361
-
362
- ## Criptiú trédhearcach
363
- Cumasaigh criptiúchán trédhearcach ar thaobh an chliaint:
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
- Cad atá ag tarlú? Rianaíonn eolaire ar leith “iontráil eolaire” (díreach) (criptithe) cad iad na comhaid atá ann
383
- eolaire (aka an eolaire díreach).
384
- * Léann an t-ordú `list` na comhaid iontrála eolaire, díchriptigh gach cosán atá liostaithe; ansin cuireann sé meiteashonraí ar ais do gach comhad
385
- * Tá orduithe `list` níos mí-éifeachtach, go háirithe i gcás eolairí a bhfuil líon mór comhad acu
386
- * Scríobhann an t-ordú `write` scríobh` comhaid dhíreacha i gcomhadlann dhírigh gach tuismitheora, go hathchúrsach; ansin scríobhann an comhad
387
- *Tabhóidh O(N) orduithe `write` , le N = doimhneacht san ordlathas eolaire
388
- * Baineann an t-ordú `remove` an comhad díreach comhfhreagrach, agus má tá a thuismitheoir folamh, go hathchúrsach; ansin bain an comhad
389
- * `remove` neamh-athfhillteacha léite O(N) agus b'fhéidir an oiread scriosadh, le N = doimhneacht san ordlathas eolaire
390
- * D’fhéadfadh orduithe `remove` athchúrsacha ar chórais comhaid mhóra agus dhomhain a bheith costasach
391
-
392
- Tabhair faoi deara, fiú agus criptiúchán ar thaobh an chliaint cumasaithe, go bhfuil ionsaitheoir lán-infheictheachta ar thaobh do fhreastalaí criptithe
393
- stórála, fiú gan an eochair, is féidir a fheiceáil fós ar an líon iomlán na n-eolairí agus cé mhéad comhad atá i ngach, agus le
394
- iarracht éigin, faigh amach ar struchtúr iomlán an ordlathais eolaire, nó cuid de.
395
- *Tabhair faoi deara: Bain úsáid as struchtúr measartha réidh le haghaidh slándála níos fearr.*
396
- Ní bheadh ainmneacha na n-eolaire/comhad ar eolas ag an sáraí mura raibh do chriptiú ar eolas acu freisin
397
- eochair nó gur éirigh leis an criptiúchán a scoilteadh. Tá gach geallta as sin!
398
-
399
- ### Feidhmíocht agus taisceadh
400
- Is féidir le hoibríochtaí ar stóráil criptithe a bheith mall. Is féidir le liostaí athfhillteacha agus aistrithe a bheith an-mhall.
401
- Cabhraíonn taisceadh trí redis go mór, ach tabhair faoi deara go ndéantar an taisce a shruthlú ar aon scríobh nó a bhaintear.
402
-
403
- ## Rothlú eochair
404
- Cruthaigh mobiletto le d'eochair nua, ansin déan na seansonraí a scáthánú isteach 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
- ## comhéadan tiománaí
417
- Is ionann tiománaí agus aon chomhad JS a easpórtálann feidhm ‘storageClient’ leis an síniú seo:
418
-
419
- function storageClient (key, secret, opts)
420
-
421
- * `key` : teaghrán, d'eochair API (don tiománaí `local` is é seo an bunchomhadlann)
422
- * `secret` : teaghrán, do rún API (is féidir é a fhágáil ar lár don tiománaí `local` )
423
- * `opts` : réad, is iad na hairíonna in aghaidh an tiománaí:
424
- * I gcás `local` , socraíonn na `fileMode` agus `dirMode` conas a chruthaítear comhaid agus eolairí nuachruthaithe
425
- * Le haghaidh `s3` , tá an mhaoin `bucket` ag teastáil. Is iad na hairíonna roghnacha:
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
- Caithfidh an réad a thugann an fheidhm storageClient ar ais na feidhmeanna seo a shainiú:
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
- ## Logáil
457
- Úsáideann Mobiletto leabharlann logála [winston](https://www.npmjs.com/package/winston).
458
-
459
- Beidh conairí comhaid agus teachtaireachtaí earráide i logaí**, ach **ní bheidh eochracha, rúin,
460
- nó aon fhaisnéis chumraíochta ceangail eile.
461
-
462
- ### Leibhéal logála
463
- Úsáid an athróg timpeallachta `MOBILETTO_LOG_LEVEL` chun an leibhéal loga a shocrú, ag baint úsáide as ceann amháin
464
- de na leibhéil `npm` atá sainmhínithe i [https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels)
465
-
466
- Is é an leibhéal réamhshocraithe ná `error` . Is é an leibhéal is briathartha ná `silly` , cé go mobiletto faoi láthair
467
- ní logálann sé ag leibhéil faoi bhun `debug`
468
-
469
- MOBILETTO_LOG_LEVEL=silly # maximum logs!
470
-
471
- ### Logchomhad
472
- De réir réamhshocraithe, scríobhann an logálaí chuig an consól. Chun logs a sheoladh chuig comhad, socraigh `MOBILETTO_LOG_FILE`
473
- athróg timpeallachta. Nuair a bheidh tú ag logáil isteach i gcomhad, ní scríobhfar logaí chuig an consól a thuilleadh.
474
-
475
- MOBILETTO_LOG_FILE=/var/my_mobiletto_log
476
-
477
- Chun logáil a mhúchadh:
478
-
479
- MOBILETTO_LOG_FILE=/dev/null
480
-
481
- </pre>