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/so/README.md DELETED
@@ -1,481 +0,0 @@
1
- Mobiletto
2
- ========
3
-
4
- Mobiletto waa lakabka kaydinta kaydinta JavaScript, oo leh sir dhinaca macmiilka ah oo ikhtiyaari ah.
5
-
6
- # Nuxurka
7
- * [Sababta Mobiletto?](#Sababta Mobiletto?)
8
- * [Bilow degdeg ah](#Si degdeg ah u bilow)
9
- * [Mobiletto CLI](#mobiletto-cli)
10
- * [Isha](#Isha)
11
- * [Rakibka](#Rakiba)
12
- * [Taageerada iyo Maalgelinta](#Taageerada-iyo Maalgelinta)
13
- * [Isticmaalka aasaasiga ah](#Isticmaalka aasaasiga ah)
14
- * [Metadata](#Metadata)
15
- * [Qaabka soo dejinta beddelka](#Habka-soo dejinta-ka beddelka)
16
- * [Caching](#Caching)
17
- * [Mirroring](#Mirroring)
18
- * [Si daah-furnaan]
19
- * [wareejinta furaha](#furaha-wareejin)
20
- * [Driver interface](#Driver-interface)
21
- * [Giritaanka](#Logging)
22
-
23
- # Ku akhri luqad kale
24
- Dukumeentigan README.md waxa lagu turjumay, iyada oo loo marayo [hokeylization](https://github.com/cobbzilla/hokeylization), galay
25
- **[Luqadda kasta oo ay taageerto Google Translate](https://cloud.google.com/translate/docs/languages)!**
26
-
27
- Waan hubaa inaysan qummanayn, laakiin waxaan rajeynayaa inay ka fiican tahay waxba!
28
-
29
- [🇸🇦 Carabi](../ar/README.md)
30
- [🇧🇩 Bengali](../bn/README.md)
31
- [🇩🇪 Jarmal](../de/README.md)
32
- [🇺🇸 Ingiriis](../en/README.md)
33
- [🇪🇸 Isbaanish](../es/README.md)
34
- [🇫🇷 Faransiis](../fr/README.md)
35
- [🇹🇩 Hausa](../ha/README.md)
36
- [🇮🇳 Hindi](../hi/README.md)
37
- [🇮🇩 Indonesian](../id/README.md)
38
- [🇮🇹 Talyaani](../it/README.md)
39
- [🇯🇵 Jabbaan](../ja/README.md)
40
- [🇰🇷 Kuuriyaan](../ko/README.md)
41
- [🇮🇳 Marathi](../mr/README.md)
42
- [🇵🇱 Polish](../pl/README.md)
43
- [🇧🇷 Boortaqiis](../pt/README.md)
44
- [🇷🇺 Ruush](../ru/README.md)
45
- [🇰🇪 Swahili](../sw/README.md)
46
- [🇵🇭 Tagalog](../tl/README.md)
47
- [🇹🇷 Turkish](../tr/README.md)
48
- [🇵🇰 Urduu](../ur/README.md)
49
- [🇻🇳 Vietnamese](../vi/README.md)
50
- [🇨🇳 Shiine](../zh/README.md)
51
-
52
-
53
- **[📚 ... Dhammaan Luqadaha ...](../README.md)**
54
- ----
55
-
56
- ### Dhib ma ka jirtaa tarjumaada README?
57
- Turjumaaddan gaarka ah ee asalka ah [README](https://github.com/cobbzilla/mobiletto/blob/master/README.md)
58
- waxaa laga yaabaa in ay cilladaysan tahay -- *sixitaanku aad ayaa loo soo dhawaynayaa!* Fadlan u soo dir [codsi jiid GitHub](https://github.com/cobbzilla/mobiletto/pulls),
59
- ama haddii aadan ku qanacsanayn inaad taas samayso, [fur arrin](https://github.com/cobbzilla/mobiletto/issues)
60
-
61
- Markaad abuurto arrin cusub oo GitHub ah oo ku saabsan tarjumaada, fadlan samee:
62
- * ku dar URL bogga (koobi/ku dheji barta ciwaanka browserka)
63
- * ku dar qoraalka saxda ah ee khaldan (koobi ka soo gal browserka)
64
- * fadlan sharax waxa khaldan -- turjumaada ma khaldan tahay? qaabaynta si uun ma u jabtay?
65
- * si naxariis leh u soo jeedi soo jeedin tarjumaad ka wanaagsan, ama sida qoraalka si habboon loo qaabeeyey
66
- * **Mahadsanid!**
67
-
68
- Waa maxay sababta Mobiletto?
69
-
70
- ### Nabad gelyo quful-iibiyaha!
71
- Bixiyeyaasha kaydinta daruuraha ee kala duwan waxay leeyihiin API-yo aan ku haboonayn Xataa kuwa ku dadaalaya "S3 waafaqsanaanta"
72
- waxay leeyihiin dabeecado aan caadi ahayn.
73
-
74
- Marka aad doorato iibiyaha kaydinta gaarka ah abkaaga, haddii aad si toos ah code ugu geliso API-ga, abkaaga
75
- hadda waxay ku tiirsan tahay adeeggaas. Marka uu wakhtigu sii socdo oo koodhka is urursado, beddelka iibiyeyaasha ayaa noqda
76
- sii kordheysa oo aan la sii wadi karin. Ku soo dhawoow dunida xiisaha leh ee qufulka iibiyaha!
77
-
78
- Mobiletto waxaa loo qorsheeyay in lagu xalliyo dhibaatadan. Markaad ku xidhid abkaaga mobiltto's API, si fudud ayaad u samayn kartaa
79
- beddel bixiyeyaasha kaydinta oo ogow in lakabka kaydinta abkaagu u dhaqmi doono si isku mid ah.
80
-
81
- ### Imtixaan baaxad leh
82
- Dhammaan darawalada waxa lagu tijaabiyaa dabeecad isku mid ah iyada oo 60+ imtixaan laga qaaday darawal kasta.
83
- Waxaan ku tijaabineynaa dhammaan darawalada isku darka kasta oo:
84
- * Sireed: labadaba waa karti iyo naafo
85
- * Redis cache: labadaba waa karti iyo naafo
86
-
87
- Habkani waxa uu ina siinaya maskaxda maskaxda in mobiletto uu u dhaqmayo si la mid ah darawalka aad isticmaasho,
88
- iyadoo aan loo eegin haddii aad karti u leedahay kaydinta iyo/ama sirta.
89
-
90
- ### Taageerada darawalka
91
- Wadayaasha kaydinta Mobiletto hadda:
92
- * `s3` : Amazon S3
93
- * `b2` : Backblaze B2
94
- * `local` : nidaamka faylalka maxalliga ah
95
-
96
- *Tabarucaadka lagu taageerayo bixiyayaasha kaydinta daruuraha aad ayaa loo soo dhawaynayaa!*
97
-
98
- ## mobiletto-cli
99
- Mobiletto waxaa loogu talagalay in loo isticmaalo maktabad ahaan koodka JavaScript kale.
100
-
101
- Si aad mobiletto ugala shaqeyso khadka taliska, isticmaal [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)
102
-
103
- ## Isha
104
- * [mobiletto on GitHub](https://github.com/cobbzilla/mobiletto)
105
- * [mobiletto onpm](https://www.npmjs.com/package/mobiletto)
106
-
107
- ## Taageerada iyo Maalgelinta
108
- Waxaan isku dayayaa inaan noqdo horumariye il furan oo xirfad leh. waan ka shaqaynayay
109
- warshadaha software-ka sanado badan, waxaan bilaabay shirkado guuleysta waxaanan ka iibiyay shirkado dadweyne.
110
- Dhowaan shaqadeydii waa iga luntay, runtiina shaqo kale oo safan ma jirto
111
-
112
- Markaa waxaan isku dayi doonaa inaan qoro software waxtar leh oo aan eego inay taasi shaqaynayso
113
-
114
- Haddii aad ku raaxaysato isticmaalka software-kan, aad baan ugu mahadcelin lahaa xataa
115
- ugu yar [wax ku darsiga billaha ah ee loo maro Patreon](https://www.patreon.com/cobbzilla)
116
-
117
- *Mahadsanid!*
118
-
119
- ## Rakibaadda
120
- Ku rakib adigoo isticmaalaya `npm` ama `yarn` . Waxaa laga yaabaa inaad rabto nooca `lite` ' oo aan ku jirin dhammaan
121
- faylasha README ee la turjumay:
122
-
123
- npm install mobiletto-lite
124
- yarn add mobiletto-lite
125
-
126
- Haddii aad runtii rabto faylasha README ee luqad kasta, ku rakib nooca buuxa:
127
-
128
- npm install mobiletto
129
- yarn add mobiletto
130
-
131
- ## Deg deg ah
132
- Tusaale gaaban oo isticmaalaya mobaylka `s3` darawalka.
133
-
134
- Koodhkani sidiisii ayuu u shaqayn lahaa haddii darawalku yahay `b2` ama `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
- ## Isticmaalka aasaasiga ah
165
- Tusaale aad u ballaaran, oo muujinaya inta badan sifooyinka la bixiyo:
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
- Amarka `metadata` wuxuu soo celiyaa xogta badan ee ku saabsan hal gelinta nidaamka faylalka.
268
- Sidoo kale, qiimaha ka soo `list` waa shay kala duwan oo xog badan ah.
269
-
270
- Shayga xogta badan ayaa sidan u eg:
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
- Hantida `type` waxay noqon kartaa `file` , `dir` , `link` , ama `special` .
281
-
282
- Iyadoo ku xiran nooca darawalka, amarka `list` waxaa laga yaabaa inuusan soo celin dhammaan goobaha. `name` iyo `type`
283
- had iyo jeer waa inay joogaan. Amarka `metadata` xiga ayaa soo celin doona dhammaan guryaha la heli karo.
284
-
285
- ## Habka soo dejinta beddelka ah
286
- Soo deji cutubka si buuxda u koobay oo isticmaal shaqada `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
- ## Kaydinta
294
- Mobiletto waxa uu si fiican ugu shaqeeyaa kaydka <a href="https://redis.io">rediska</a> .
295
-
296
- Mobiletto waxay isku dayi doontaa inay ku xidho tusaale redis 127.0.0.1:6379
297
-
298
- Waxaad ka saari kartaa mid ka mid ah kuwan:
299
- * Deji `MOBILETTO_REDIS_HOST` env var, mobiletto ku xidh halkan halkii aad ka isticmaali lahayd localhost
300
- * Deji `MOBILETTO_REDIS_PORT` env var, dekeddan waa la isticmaali doonaa
301
-
302
- Mobiletto waxa ay ku kaydin doontaa dhamaan furayaashiisa rediska oo wata horgalaha `_mobiletto__` . Waad bedeli kartaa tan
303
- adoo dejinaya `MOBILETTO_REDIS_PREFIX` env var.
304
-
305
- Waxa kale oo aad dejin kartaa khasnad kasta oo ku xidhan shayga `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
- ### Ma rabtaa inaad kaydiso redis?
317
- Si aad u damiso: gudbi `enabled: false` ' shayga `opts.redisConfig` markaad samaysato xidhiidhkaaga.
318
-
319
- Sida hoos looga hadlay, curyaaminta kaydinta waxay saameyn xun ku yeelan doontaa waxqabadka waxayna keeneysaa codsiyo badan
320
- kaydinta aad runtii u baahan tahay.
321
-
322
- ### hagida kaydinta
323
- ** Kaydinta dahsoon ***: akhrinta/qorista kaydinta sir ah ayaa kayar ka yar sidii caadiga ahayd,
324
- Laakin ku wareegitaanka hagayaasha (kuwaasi oo waxyaabaha qaarkood ay sameeyaan) waa qaali. Isticmaalka kaydka redis
325
- waxay ku siin doontaa kor u qaadida waxqabadka muhiimka ah.
326
-
327
- Cache-ga caadiga ah waa badbaado, laakiin si fiican uma shaqeeyo haddii aad leedahay wax badan oo qoraal ah / ka saar.
328
- Hawl kasta oo qoraal ah ama ka saar ahi waxay burinaysaa kaydka oo dhan, iyada oo hubinaysa in akhrinta xigta ay arki doonto
329
- isbedeladii ugu dambeeyay.
330
-
331
- ### Qalabka CLI
332
- Haddii aad isticmaalayso aaladda CLI sida [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
333
- Xaqiiqdi waxaad u baahan doontaa in redis cache la furo, maadaama ay ku dhamaanayso `mo` amarka 'mo'.
334
-
335
- ## Milicsiga
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
- Amarka `mirror` waxa uu sameeyaa koobi hal mar ah dhammaan faylalka min mobiletto ilaa mid kale.
344
- Ma socodsiiso hab kasta oo lagu ilaalinayo muraayadda waqti ka dib. `mirror` mar kale
345
- si loo waafajiyo wixii faylal maqan.
346
-
347
- Qiimaha soo celinta `mirror` waa shay fudud oo leh xisaabiye inta faylal si guul leh loo gaaray
348
- miraayad leh iyo imisa faylal ayaa khaldamay:
349
-
350
- {
351
- success: count-of-files-mirrored,
352
- errors: count-of-files-with-errors
353
- }
354
-
355
- DIGNIIN: Milicsiga xogaha waaweyn waxay noqon kartaa waqti-qaadasho iyo baaxad-weyn
356
-
357
- `mirror` waxa ay mararka qaarkood noqon kartaa jahawareer in la fahmo cidda
358
- akhriste iyo waa kuma qoraaga. Ka soo qaad sida qoraalka shaqada: "mobiletto-gacanta bidix"
359
- waa waxa loo qoondeeyay (xogta muraayada la qoray), iyo "mobiletto gacanta midig" (the
360
- doodda habka `mirror` ) waa qiimaha la qoondeeyey (xogta muraayadda waa la akhriyaa).
361
-
362
- ## Sirin hufan
363
- Daar si hufan oo dhinaca macmiilka ah:
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
- Maxaa dhacaya? Meel gaar ah oo "galitaan tusaha" (dirent) hagaha ( sir ah) ayaa la socda waxa faylalka ku jira
383
- tusaha (oo loo yaqaan tusaha tooska ah).
384
- * Amarka `list` wuxuu akhriyaa galka galka tusaha, wuxuu furfuraa waddo kasta oo taxan; ka dibna u soo celisa xogta badan ee fayl kasta
385
- * `list` waa kuwo aan waxtar lahayn, gaar ahaan hagayaasha leh tiro badan oo faylal ah
386
- * Amarka `write` wuxuu ku qoraa faylal kala duwan tusaha tooska ah ee waalid kasta, si isdaba joog ah; markaas buu qorayaa faylka
387
- * `write` waxay keenaysaa O(N) qorta, iyadoo N = qoto dheer ay ku jirto kala sareynta hagaha
388
- * Amarka `remove` wuxuu meesha ka saarayaa faylka tooska ah ee u dhigma, iyo waalidkii haddii uu madhan yahay, si isdaba joog ah; ka dibna ka saara faylka
389
- * `remove` ee aan soo noqnoqoneynin waxay keenaysaa O(N) akhrinta iyo suurtogalnimada in la tirtiro, iyadoo N = qoto dheer ay ku jirto kala sareynta hagaha
390
- * `remove` ee soo noqnoqda ee nidaamyada faylalka waaweyn iyo kuwa qoto dheer waxay noqon karaan qaali
391
-
392
- Ogsoonow in xitaa iyada oo sirta-dhinaca macmiilku karti u yeeshay, cadow si buuxda u muuqda dhanka server-kaaga sir ah
393
- kaydinta, xitaa furaha la'aanteed, waxay weli arki kartaa tirada guud ee hagayaasha iyo inta fayl ee mid kasta ku jira, iyo la
394
- xoogaa dadaal ah, hel qaar ama dhammaan qaab dhismeedka guud ee kala sareynta hagaha.
395
- *Fiiro gaar ah: Isticmaal qaab dhismeed siman si aad u hesho ammaan wanaagsan.*
396
- Cadawgu ma garan doono magacyada hagayaasha/faylalka ilaa ay sidoo kale ogaadaan sirtaada mooyaane
397
- furaha ama haddii kale si guul leh u dillaacay sirta. Dhammaan khamaaradaha waa damsan yihiin markaa!
398
-
399
- ### Waxqabadka iyo kaydinta
400
- Hawlgallada kaydinta sirta ah waxay noqon karaan kuwo gaabis ah. Liisaska soo noqnoqda iyo ka saarista waxay noqon kartaa mid aad u gaabis ah.
401
- Ku kaydinta redis aad bay u caawisaa, laakiin ogow in kaydku ku daatay wax kasta oo la qoro ama laga saaro.
402
-
403
- ## Wareegtada furaha ah
404
- Ku samee mobiltto furahaaga cusub, ka dibna u miiri xogtii hore:
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
- ## interface darawalka
417
- Darawalku waa fayl kasta oo JS ah oo dhoofiya shaqada 'kaydinta macmiilka' oo leh saxeexan:
418
-
419
- function storageClient (key, secret, opts)
420
-
421
- * `key` : xarig, furahaaga API (darawalka `local` ' kani waa tusaha saldhiga)
422
- * `secret` : xarig, sirtaada API (waxaa laga saari karaa darawalka `local` ')
423
- * `opts` : shay, alaabtu waa darawal kasta:
424
- * Wixii `local` ah, `fileMode` iyo `dirMode` guryaha ayaa go'aamiya sida abuurista cusub ee faylasha iyo hagayaasha loo abuuray
425
- * Wixii `s3` , hantida `bucket` ayaa loo baahan yahay. Guryaha ikhtiyaariga ah waa:
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
- Shayga uu soo celiyo shaqada Macmiilku waa inuu qeexaa shaqooyinkan:
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
- ## Gelida
457
- Mobiletto waxay isticmaashaa [winston](https://www.npmjs.com/package/winston)
458
-
459
- Logs ** waxay ka koobnaan doonaan wadooyinka faylalka iyo fariimaha khaladka ah, laakiin ** waligiis kama koobnaan doono furayaal, siro,
460
- ama macluumaad kasta oo qaabeynta isku xirka.
461
-
462
- ### Heer gal
463
- Isticmaal `MOBILETTO_LOG_LEVEL` doorsoomiyaha deegaanka si aad u dejiso heerka log, addoo isticmaalaya mid
464
- ee heerarka `npm` lagu qeexay [https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels)
465
-
466
- Heerka caadiga ah waa `error` . Heerka ugu afka badan waa `silly` , inkastoo hadda mobiletto
467
- ma gasho heerarka ka hooseeya `debug`
468
-
469
- MOBILETTO_LOG_LEVEL=silly # maximum logs!
470
-
471
- ### Gal gal
472
- Sida caadiga ah, loggerku wuxuu wax u qoraa console-ka. Si aad diiwaannada ugu dirto faylka, deji `MOBILETTO_LOG_FILE`
473
- doorsooma deegaan. Markaad galeyso fayl, diiwaannada laguma qori doono console-ka.
474
-
475
- MOBILETTO_LOG_FILE=/var/my_mobiletto_log
476
-
477
- Si aad u damiso goynta:
478
-
479
- MOBILETTO_LOG_FILE=/dev/null
480
-
481
- </pre>