mobiletto 1.1.10 → 1.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +74 -0
  2. package/docs/README.md +113 -0
  3. package/docs/af/README.md +481 -0
  4. package/docs/am/README.md +481 -0
  5. package/docs/ar/README.md +481 -0
  6. package/docs/az/README.md +481 -0
  7. package/docs/be/README.md +481 -0
  8. package/docs/bg/README.md +481 -0
  9. package/docs/bn/README.md +481 -0
  10. package/docs/bs/README.md +481 -0
  11. package/docs/ca/README.md +481 -0
  12. package/docs/ceb/README.md +481 -0
  13. package/docs/co/README.md +481 -0
  14. package/docs/cs/README.md +481 -0
  15. package/docs/cy/README.md +481 -0
  16. package/docs/da/README.md +481 -0
  17. package/docs/de/README.md +481 -0
  18. package/docs/el/README.md +481 -0
  19. package/docs/eo/README.md +481 -0
  20. package/docs/es/README.md +481 -0
  21. package/docs/et/README.md +481 -0
  22. package/docs/eu/README.md +481 -0
  23. package/docs/fa/README.md +481 -0
  24. package/docs/fi/README.md +481 -0
  25. package/docs/fr/README.md +481 -0
  26. package/docs/fy/README.md +481 -0
  27. package/docs/ga/README.md +481 -0
  28. package/docs/gd/README.md +481 -0
  29. package/docs/gl/README.md +481 -0
  30. package/docs/gu/README.md +481 -0
  31. package/docs/ha/README.md +481 -0
  32. package/docs/haw/README.md +481 -0
  33. package/docs/he/README.md +481 -0
  34. package/docs/hi/README.md +481 -0
  35. package/docs/hmn/README.md +481 -0
  36. package/docs/hr/README.md +481 -0
  37. package/docs/ht/README.md +481 -0
  38. package/docs/hu/README.md +481 -0
  39. package/docs/hy/README.md +481 -0
  40. package/docs/id/README.md +481 -0
  41. package/docs/ig/README.md +481 -0
  42. package/docs/is/README.md +481 -0
  43. package/docs/it/README.md +481 -0
  44. package/docs/iw/README.md +481 -0
  45. package/docs/ja/README.md +481 -0
  46. package/docs/jv/README.md +481 -0
  47. package/docs/ka/README.md +481 -0
  48. package/docs/kk/README.md +481 -0
  49. package/docs/km/README.md +481 -0
  50. package/docs/kn/README.md +481 -0
  51. package/docs/ko/README.md +481 -0
  52. package/docs/ku/README.md +481 -0
  53. package/docs/ky/README.md +481 -0
  54. package/docs/la/README.md +481 -0
  55. package/docs/lb/README.md +481 -0
  56. package/docs/lo/README.md +481 -0
  57. package/docs/lt/README.md +481 -0
  58. package/docs/lv/README.md +481 -0
  59. package/docs/mg/README.md +481 -0
  60. package/docs/mi/README.md +481 -0
  61. package/docs/mk/README.md +481 -0
  62. package/docs/ml/README.md +481 -0
  63. package/docs/mn/README.md +481 -0
  64. package/docs/mr/README.md +481 -0
  65. package/docs/ms/README.md +481 -0
  66. package/docs/mt/README.md +481 -0
  67. package/docs/my/README.md +481 -0
  68. package/docs/ne/README.md +481 -0
  69. package/docs/nl/README.md +481 -0
  70. package/docs/no/README.md +481 -0
  71. package/docs/ny/README.md +481 -0
  72. package/docs/or/README.md +481 -0
  73. package/docs/pa/README.md +481 -0
  74. package/docs/pl/README.md +481 -0
  75. package/docs/ps/README.md +481 -0
  76. package/docs/pt/README.md +481 -0
  77. package/docs/ro/README.md +481 -0
  78. package/docs/ru/README.md +481 -0
  79. package/docs/rw/README.md +481 -0
  80. package/docs/sd/README.md +481 -0
  81. package/docs/si/README.md +481 -0
  82. package/docs/sk/README.md +481 -0
  83. package/docs/sl/README.md +481 -0
  84. package/docs/sm/README.md +481 -0
  85. package/docs/sn/README.md +481 -0
  86. package/docs/so/README.md +481 -0
  87. package/docs/sq/README.md +481 -0
  88. package/docs/sr/README.md +481 -0
  89. package/docs/st/README.md +481 -0
  90. package/docs/su/README.md +481 -0
  91. package/docs/sv/README.md +481 -0
  92. package/docs/sw/README.md +481 -0
  93. package/docs/ta/README.md +481 -0
  94. package/docs/te/README.md +481 -0
  95. package/docs/tg/README.md +481 -0
  96. package/docs/th/README.md +481 -0
  97. package/docs/tk/README.md +481 -0
  98. package/docs/tl/README.md +481 -0
  99. package/docs/tr/README.md +481 -0
  100. package/docs/tt/README.md +481 -0
  101. package/docs/ug/README.md +481 -0
  102. package/docs/uk/README.md +481 -0
  103. package/docs/ur/README.md +481 -0
  104. package/docs/uz/README.md +481 -0
  105. package/docs/vi/README.md +481 -0
  106. package/docs/xh/README.md +481 -0
  107. package/docs/yi/README.md +481 -0
  108. package/docs/yo/README.md +481 -0
  109. package/docs/zh/README.md +481 -0
  110. package/docs/zu/README.md +481 -0
  111. package/drivers/b2/index.js +25 -6
  112. package/hokey.json +16 -0
  113. package/index.js +7 -2
  114. package/package.json +1 -1
  115. package/test/api.spec.js +13 -9
  116. package/util/redis.js +2 -2
@@ -0,0 +1,481 @@
1
+ Mobiletto
2
+ =========
3
+
4
+ Mobiletto është një shtresë abstraksioni i ruajtjes së JavaScript, me enkriptim transparent opsional nga ana e klientit.
5
+
6
+ # Përmbajtje
7
+ * [Pse Mobiletto?](#Pse-Mobiletto?)
8
+ * [Fillimi i shpejtë](#Fillimi i shpejtë)
9
+ * [Mobiletto CLI](#mobiletto-cli)
10
+ * [Burimi](#Burimi)
11
+ * [Instalim](#Instalim)
12
+ * [Mbështetje dhe financim](#Support-and-Funding)
13
+ * [Përdorimi bazë](#Basic-usage)
14
+ * [Metadata](#Metadata)
15
+ * [Stil alternativ importi](#Alternate-import-style)
16
+ * [Caching](#Caching)
17
+ * [Pasqyrim](#Pasqyrim)
18
+ * [Kriptimi transparent](#Transparent-encryption)
19
+ * [Rrotullimi i çelësit](#Rrotullimi i çelësit)
20
+ * [Ndërfaqja e shoferit](#Driver-interface)
21
+ * [Logging](#Logging)
22
+
23
+ # Lexojeni këtë në një gjuhë tjetër
24
+ Ky dokument README.md është përkthyer, nëpërmjet [hokeylization](https://github.com/cobbzilla/hokeylization), në
25
+ **[çdo gjuhë e mbështetur nga Google Translate](https://cloud.google.com/translate/docs/languages)!**
26
+
27
+ Jam i sigurt se nuk është perfekt, por shpresoj të jetë më mirë se asgjë!
28
+
29
+ [🇸🇦 Arabisht](../ar/README.md)
30
+ [🇧🇩 Bengalisht](../bn/README.md)
31
+ [🇩🇪 gjermanisht](../de/README.md)
32
+ [🇺🇸 Anglisht](../en/README.md)
33
+ [🇪🇸 spanjisht](../es/README.md)
34
+ [🇫🇷 Frengjisht](../fr/README.md)
35
+ [🇹🇩 Hausa](../ha/README.md)
36
+ [🇮🇳 Hindi](../hi/README.md)
37
+ [🇮🇩 Indonezisht](../id/README.md)
38
+ [🇮🇹 Italisht](../it/README.md)
39
+ [🇯🇵 Japonisht](../ja/README.md)
40
+ [🇰🇷 Koreane](../ko/README.md)
41
+ [🇮🇳 Maranthi](../mr/README.md)
42
+ [🇵🇱 Polonisht](../pl/README.md)
43
+ [🇧🇷 Portugeze](../pt/README.md)
44
+ [🇷🇺 Rusisht](../ru/README.md)
45
+ [🇰🇪 Suahili](../sw/README.md)
46
+ [🇵🇭 Tagalog](../tl/README.md)
47
+ [🇹🇷 Turqisht](../tr/README.md)
48
+ [🇵🇰 Urdu](../ur/README.md)
49
+ [🇻🇳 Vietnamisht](../vi/README.md)
50
+ [🇨🇳 Kinezisht](../zh/README.md)
51
+
52
+
53
+ **[📚 ... Të gjitha gjuhët ...](../README.md)**
54
+ ----
55
+
56
+ ### A ka ndonjë problem me këtë përkthim të README?
57
+ Ky përkthim i veçantë i origjinalit [README](https://github.com/cobbzilla/mobiletto/blob/master/README.md)
58
+ mund të jetë me të meta -- *korrigjimet janë shumë të mirëseardhura!* Ju lutemi dërgoni një [kërkesë për tërheqje në GitHub](https://github.com/cobbzilla/mobiletto/pulls),
59
+ ose nëse nuk jeni të kënaqur ta bëni këtë, [hapni një çështje](https://github.com/cobbzilla/mobiletto/issues)
60
+
61
+ Kur krijoni një problem të ri të GitHub në lidhje me një përkthim, ju lutemi bëni:
62
+ * përfshini URL-në e faqes (kopjoni/ngjisni nga shiriti i adresave të shfletuesit)
63
+ * përfshini tekstin e saktë që është i gabuar (kopjoni/ngjisni nga shfletuesi)
64
+ * ju lutemi përshkruani se çfarë nuk shkon -- a është përkthimi i gabuar? a është thyer disi formatimi?
65
+ * me mirësi ofroni një sugjerim për një përkthim më të mirë, ose se si teksti duhet të formatohet siç duhet
66
+ * **Faleminderit!**
67
+
68
+ ## Pse Mobiletto?
69
+
70
+ ### Mirupafshim mbyllje e shitësit!
71
+ Ofruesit e ndryshëm të ruajtjes së cloud kanë API të papajtueshme. Edhe ata që përpiqen për "përputhshmërinë S3"
72
+ kanë sjellje idiosinkratike.
73
+
74
+ Kur zgjidhni një shitës të veçantë ruajtjeje për aplikacionin tuaj, nëse kodoni drejtpërdrejt në API-në e tyre, aplikacionin tuaj
75
+ tani është i varur nga ai shërbim. Me kalimin e kohës dhe grumbullimin e kodit, ndryshimi i shitësve bëhet
76
+ gjithnjë e më e paqëndrueshme. Mirë se vini në botën argëtuese të mbylljes së shitësve!
77
+
78
+ Mobiletto u krijua për të zgjidhur këtë problem. Duke koduar aplikacionin tuaj në API-në e mobiletto, ju mund të lehtë
79
+ ndryshoni ofruesit e ruajtjes dhe dijeni se shtresa e ruajtjes së aplikacionit tuaj do të sillet në mënyrë identike.
80
+
81
+ ### Testim i gjerë
82
+ Të gjithë drejtuesit testohen për sjellje identike me mbi 60 teste për çdo shofer.
83
+ Ne testojmë të gjithë drejtuesit me çdo kombinim të:
84
+ * Kriptimi: i aktivizuar dhe i çaktivizuar
85
+ * Redis cache: si i aktivizuar ashtu edhe i çaktivizuar
86
+
87
+ Kjo qasje na jep paqe mendore se mobiletto do të sillet njësoj pavarësisht nga shoferi që përdorni,
88
+ dhe pavarësisht nëse aktivizoni memorien dhe/ose enkriptimin.
89
+
90
+ ### Mbështetje e shoferit
91
+ Drejtuesit aktualë të ruajtjes Mobiletto:
92
+ * `s3` : Amazon S3
93
+ * `b2` : Backblaze B2
94
+ * `local` : sistemi i skedarëve lokal
95
+
96
+ *Kontributet për të mbështetur më shumë ofrues të ruajtjes së cloud janë shumë të mirëseardhura!*
97
+
98
+ ## celulartto-cli
99
+ Mobiletto synohet të përdoret si bibliotekë nga kode të tjera JavaScript.
100
+
101
+ Për të punuar me mobiletto në linjën e komandës, përdorni [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)
102
+
103
+ ## Burimi
104
+ * [mobiletto në GitHub](https://github.com/cobbzilla/mobiletto)
105
+ * [mobiletto në npm](https://www.npmjs.com/package/mobiletto)
106
+
107
+ ## Mbështetje dhe financim
108
+ Po përpiqem të jem një zhvillues profesionist i softuerit me burim të hapur. Unë kam punuar në
109
+ në industrinë e softuerit për shumë vite, kam krijuar kompani të suksesshme dhe ua kam shitur kompanive publike.
110
+ Kohët e fundit kam humbur punën time dhe nuk kam asnjë punë tjetër të rreshtuar
111
+
112
+ Kështu që unë do të përpiqem të shkruaj softuer të dobishëm dhe të shikoj nëse funksionon
113
+
114
+ Nëse ju pëlqen të përdorni këtë softuer, do të isha shumë mirënjohës edhe për këtë
115
+ më i vogël [kontributi mujor nëpërmjet Patreon](https://www.patreon.com/cobbzilla)
116
+
117
+ *Faleminderit!*
118
+
119
+ ## Instalimi
120
+ Instaloni duke përdorur `npm` " ose `yarn` . Ju ndoshta dëshironi versionin `lite` që nuk i përfshin të gjitha
121
+ Skedarët e përkthyer README:
122
+
123
+ npm install mobiletto-lite
124
+ yarn add mobiletto-lite
125
+
126
+ Nëse vërtet dëshironi skedarët README në çdo gjuhë, instaloni versionin e plotë:
127
+
128
+ npm install mobiletto
129
+ yarn add mobiletto
130
+
131
+ ## Fillim i shpejte
132
+ Një shembull i shkurtër duke përdorur drejtuesin e mobiletto `s3` .
133
+
134
+ Ky kod do të funksiononte njësoj nëse drejtuesi do të ishte `b2` " ose `local` .
135
+
136
+ const storage = require('mobiletto')
137
+ const bucket = await storage.connect('s3', aws_key, aws_secret, {bucket: 'bk'})
138
+
139
+ // list objects: returns array of metadata objects
140
+ const listing = await bucket.list()
141
+ const dirList = await bucket.list('some/dir/')
142
+ const everything = await bucket.list('', {recursive: true})
143
+
144
+ // write an entire file
145
+ let bytesWritten = await bucket.writeFile('some/path', someBufferOfData)
146
+
147
+ // write a file from a stream/generator
148
+ bytesWritten = await bucket.write('some/path', streamOrGenerator)
149
+
150
+ // read an entire file
151
+ // returns null if an exception would otherwise be thrown
152
+ const bufferOrNull = await bucket.safeReadFile('some/path')
153
+
154
+ // stream-read a file, passing data to callback
155
+ const bytesRead = await bucket.read('some/path', (chunk) => { ...do something with chunk... } )
156
+
157
+ // remove a file, returns the path removed
158
+ let removed = await bucket.remove('some/path') // removed is a string
159
+
160
+ // remove a directory, returns array of paths removed
161
+ removed = await bucket.remove('some/directory', {recursive: true}) // removed is now an array!
162
+
163
+ ----
164
+ ## Përdorimi bazë
165
+ Një shembull shumë më i gjerë, që tregon shumicën e veçorive të ofruara:
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
+ ## Të dhënat meta
267
+ Komanda `metadata` kthen meta të dhënat për një hyrje të vetme të sistemit të skedarëve.
268
+ Po kështu, vlera e kthyer nga komanda `list` është një grup objektesh meta të dhënash.
269
+
270
+ Një objekt i meta të dhënave duket kështu:
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
+ `type` mund të jetë `file` `dir` , 'dir', `link` , ose `special` .
281
+
282
+ Në varësi të llojit të drejtuesit, një komandë `list` mund të mos kthejë të gjitha fushat. `name` " dhe `type`
283
+ duhet të jetë gjithmonë i pranishëm. Një komandë e mëpasshme `metadata` do të kthejë të gjitha vetitë e disponueshme.
284
+
285
+ ## Stili i importit alternativ
286
+ Importoni modulin me shtrirje të plotë dhe përdorni funksionin `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
+ ## Caching
294
+ Mobiletto funksionon më mirë me një cache <a href="https://redis.io">redis</a> .
295
+
296
+ Mobiletto do të përpiqet të lidhet me një shembull redis në 127.0.0.1:6379
297
+
298
+ Ju mund të anashkaloni njërën nga këto:
299
+ * Vendosni `MOBILETTO_REDIS_HOST` env var, celular për t'u lidhur këtu në vend të hostit lokal
300
+ * Vendosni `MOBILETTO_REDIS_PORT` env var, kjo portë do të përdoret
301
+
302
+ Mobiletto do të ruajë të gjithë çelësat e tij redis me prefiksin `_mobiletto__` . Ju mund ta ndryshoni këtë
303
+ duke vendosur `MOBILETTO_REDIS_PREFIX` .
304
+
305
+ Ju gjithashtu mund të caktoni caching për lidhje me objektin `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
+ ### Nuk dëshironi redis caching?
317
+ Për të çaktivizuar: kaloni `enabled: false` " në objektin tuaj `opts.redisConfig` kur krijoni lidhjen tuaj.
318
+
319
+ Siç diskutohet më poshtë, çaktivizimi i memorjes në memorie do të ketë një efekt negativ në performancën dhe do të shkaktojë më shumë kërkesa
320
+ në ruajtje që ju duhet vërtet.
321
+
322
+ ### Udhëzime për ruajtjen e memories
323
+ **Magazinimi i koduar**: leximi/shkrimi i ruajtjes së koduar është vetëm pak më i ngadalshëm se normalja,
324
+ por lundrimi nëpër drejtori (që disa gjëra e bëjnë) është mjaft i shtrenjtë. Përdorimi i një cache redis
325
+ do t'ju japë një rritje të konsiderueshme të performancës.
326
+
327
+ Memoria e paracaktuar është e sigurt, por nuk funksionon mirë nëse keni shumë operacione shkrimi/fshirjeje.
328
+ Çdo operacion shkrimi ose heqjeje e zhvlerëson të gjithë memorien e fshehtë, duke siguruar që leximet e mëvonshme do ta shohin atë
329
+ ndryshimet e fundit.
330
+
331
+ ### Mjetet CLI
332
+ Nëse jeni duke përdorur një mjet CLI si [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
333
+ patjetër që do të dëshironi që cache-i redis të aktivizohet, pasi zgjat gjatë thirrjeve të komandës `mo` .
334
+
335
+ ## Pasqyrim
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
+ `mirror` kryen një kopje një herë të të gjithë skedarëve nga një celular në tjetrin.
344
+ Nuk kryen asnjë proces për të ruajtur pasqyrën me kalimin e kohës. Ekzekutoni përsëri komandën `mirror`
345
+ për të sinkronizuar çdo skedar që mungon.
346
+
347
+ Vlera e kthyer nga `mirror` është një objekt i thjeshtë me numërues për numrin e skedarëve të suksesshëm
348
+ pasqyruar dhe sa skedarë kishin gabime:
349
+
350
+ {
351
+ success: count-of-files-mirrored,
352
+ errors: count-of-files-with-errors
353
+ }
354
+
355
+ PARALAJMËRIM: Pasqyrimi i grupeve të mëdha të të dhënave mund të marrë shumë kohë dhe me gjerësi brezi
356
+
357
+ Me semantikën e quajtur `mirror` , ndonjëherë mund të jetë konfuze të kuptosh se kush është
358
+ lexuesi dhe kush është shkrimtari. Imagjinoni si një deklaratë detyre: "mobili i dorës së majtë"
359
+ është gjëja që i është caktuar (të dhënat e pasqyruara janë shkruar), dhe "celulari i dorës së djathtë" (i
360
+ argumenti i metodës `mirror` ) është vlera që caktohet (lexohen të dhënat e pasqyruara).
361
+
362
+ ## Kriptim transparent
363
+ Aktivizo kriptim transparent nga ana e klientit:
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
+ Cfare po ndodh? Një direktori e veçantë "hyrje në direktori" (dirent) (i koduar) gjurmon se cilat skedarë janë në të
383
+ drejtoria (aka direktoria dirent).
384
+ * `list` lexon skedarët e hyrjes në drejtori, deshifron çdo shteg të listuar; pastaj kthen meta të dhënat për çdo skedar
385
+ * `list` janë më joefikase, veçanërisht për drejtoritë me një numër të madh skedarësh
386
+ * `write` shkruan skedarë dirent në drejtorinë dirent të secilit prind, në mënyrë rekursive; pastaj shkruan skedarin
387
+ * `write` do të shkaktojnë shkrime O(N), me N = thellësi në hierarkinë e drejtorisë
388
+ * `remove` heq skedarin dirent përkatës dhe prindin e tij nëse është bosh, në mënyrë rekursive; pastaj heq skedarin
389
+ * Komandat jo-rekurzive të `remove` do të shkaktojnë lexime O(N) dhe potencialisht po aq fshirje, me N = thellësi në hierarkinë e drejtorisë
390
+ * Komandat rekursive `remove` në sisteme skedarësh të mëdhenj dhe të thellë mund të jenë të shtrenjta
391
+
392
+ Vini re se edhe me enkriptimin nga ana e klientit të aktivizuar, një kundërshtar me shikueshmëri të plotë në anën tuaj të koduar nga serveri
393
+ ruajtja, edhe pa çelësin, mund të shohë përsëri numrin e përgjithshëm të drejtorive dhe sa skedarë janë në secilën prej tyre dhe me
394
+ disa përpjekje, zbuloni disa ose të gjithë strukturën e përgjithshme të hierarkisë së drejtorive.
395
+ *Shënim: Përdorni një strukturë relativisht të sheshtë për siguri më të mirë.*
396
+ Kundërshtari nuk do t'i dinte emrat e drejtorive/skedarëve nëse nuk dinte gjithashtu enkriptimin tuaj
397
+ kyç ose kishte thyer me sukses kriprimin. Të gjitha bastet janë jashtë atëherë!
398
+
399
+ ### Performanca dhe caching
400
+ Operacionet në ruajtjen e koduar mund të jenë të ngadalta. Listimet dhe heqjet rekursive mund të jenë shumë të ngadalta.
401
+ Memoria e memories nëpërmjet redis ndihmon jashtëzakonisht shumë, por kini parasysh se memoria e fshehtë shpërndahet pas çdo shkrimi ose heqjeje.
402
+
403
+ ## Rrotullimi i tastit
404
+ Krijoni një celular me çelësin tuaj të ri, më pas pasqyroni të dhënat e vjetra në të:
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
+ ## Ndërfaqja e shoferit
417
+ Një drejtues është çdo skedar JS që eksporton një funksion 'storageClient' me këtë nënshkrim:
418
+
419
+ function storageClient (key, secret, opts)
420
+
421
+ * `key` : një varg, çelësi juaj API (për drejtuesin `local` ky është drejtoria bazë)
422
+ * `secret` : një varg, sekreti juaj i API-së (mund të hiqet për drejtuesin `local` )
423
+ * `opts` : një objekt, vetitë janë për drejtues:
424
+ * Për `local` , `fileMode` " dhe `dirMode` përcaktojnë se si krijohen skedarë dhe drejtori të reja të krijimit
425
+ * Për `s3` , kërkohet `bucket` . Karakteristikat opsionale janë:
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
+ Objekti që kthen funksioni storageClient duhet të përcaktojë këto funksione:
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
+ ## Regjistrimi
457
+ Mobiletto përdor bibliotekën e regjistrimit [winston](https://www.npmjs.com/package/winston).
458
+
459
+ Regjistrat **do** të përmbajnë shtigje skedarësh dhe mesazhe gabimi, por **nuk** do të përmbajnë çelësa, sekrete,
460
+ ose ndonjë informacion tjetër për konfigurimin e lidhjes.
461
+
462
+ ### Niveli i regjistrit
463
+ Përdorni variablin e mjedisit `MOBILETTO_LOG_LEVEL` për të vendosur nivelin e regjistrit, duke përdorur një
464
+ e niveleve `npm` të përcaktuara në [https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels)
465
+
466
+ Niveli i parazgjedhur është `error` . Niveli më i folur është `silly` , megjithëse aktualisht është i lëvizshëm
467
+ nuk regjistrohet në nivele nën `debug`
468
+
469
+ MOBILETTO_LOG_LEVEL=silly # maximum logs!
470
+
471
+ ### Skedari i regjistrit
472
+ Si parazgjedhje, regjistruesi shkruan në tastierë. Për të dërguar regjistrat në një skedar, caktoni `MOBILETTO_LOG_FILE`
473
+ variabli i mjedisit. Kur regjistroheni në një skedar, regjistrat nuk do të shkruhen më në tastierë.
474
+
475
+ MOBILETTO_LOG_FILE=/var/my_mobiletto_log
476
+
477
+ Për të çaktivizuar regjistrimin:
478
+
479
+ MOBILETTO_LOG_FILE=/dev/null
480
+
481
+ </pre>