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.
- package/README.md +74 -0
- package/docs/README.md +113 -0
- package/docs/af/README.md +481 -0
- package/docs/am/README.md +481 -0
- package/docs/ar/README.md +481 -0
- package/docs/az/README.md +481 -0
- package/docs/be/README.md +481 -0
- package/docs/bg/README.md +481 -0
- package/docs/bn/README.md +481 -0
- package/docs/bs/README.md +481 -0
- package/docs/ca/README.md +481 -0
- package/docs/ceb/README.md +481 -0
- package/docs/co/README.md +481 -0
- package/docs/cs/README.md +481 -0
- package/docs/cy/README.md +481 -0
- package/docs/da/README.md +481 -0
- package/docs/de/README.md +481 -0
- package/docs/el/README.md +481 -0
- package/docs/eo/README.md +481 -0
- package/docs/es/README.md +481 -0
- package/docs/et/README.md +481 -0
- package/docs/eu/README.md +481 -0
- package/docs/fa/README.md +481 -0
- package/docs/fi/README.md +481 -0
- package/docs/fr/README.md +481 -0
- package/docs/fy/README.md +481 -0
- package/docs/ga/README.md +481 -0
- package/docs/gd/README.md +481 -0
- package/docs/gl/README.md +481 -0
- package/docs/gu/README.md +481 -0
- package/docs/ha/README.md +481 -0
- package/docs/haw/README.md +481 -0
- package/docs/he/README.md +481 -0
- package/docs/hi/README.md +481 -0
- package/docs/hmn/README.md +481 -0
- package/docs/hr/README.md +481 -0
- package/docs/ht/README.md +481 -0
- package/docs/hu/README.md +481 -0
- package/docs/hy/README.md +481 -0
- package/docs/id/README.md +481 -0
- package/docs/ig/README.md +481 -0
- package/docs/is/README.md +481 -0
- package/docs/it/README.md +481 -0
- package/docs/iw/README.md +481 -0
- package/docs/ja/README.md +481 -0
- package/docs/jv/README.md +481 -0
- package/docs/ka/README.md +481 -0
- package/docs/kk/README.md +481 -0
- package/docs/km/README.md +481 -0
- package/docs/kn/README.md +481 -0
- package/docs/ko/README.md +481 -0
- package/docs/ku/README.md +481 -0
- package/docs/ky/README.md +481 -0
- package/docs/la/README.md +481 -0
- package/docs/lb/README.md +481 -0
- package/docs/lo/README.md +481 -0
- package/docs/lt/README.md +481 -0
- package/docs/lv/README.md +481 -0
- package/docs/mg/README.md +481 -0
- package/docs/mi/README.md +481 -0
- package/docs/mk/README.md +481 -0
- package/docs/ml/README.md +481 -0
- package/docs/mn/README.md +481 -0
- package/docs/mr/README.md +481 -0
- package/docs/ms/README.md +481 -0
- package/docs/mt/README.md +481 -0
- package/docs/my/README.md +481 -0
- package/docs/ne/README.md +481 -0
- package/docs/nl/README.md +481 -0
- package/docs/no/README.md +481 -0
- package/docs/ny/README.md +481 -0
- package/docs/or/README.md +481 -0
- package/docs/pa/README.md +481 -0
- package/docs/pl/README.md +481 -0
- package/docs/ps/README.md +481 -0
- package/docs/pt/README.md +481 -0
- package/docs/ro/README.md +481 -0
- package/docs/ru/README.md +481 -0
- package/docs/rw/README.md +481 -0
- package/docs/sd/README.md +481 -0
- package/docs/si/README.md +481 -0
- package/docs/sk/README.md +481 -0
- package/docs/sl/README.md +481 -0
- package/docs/sm/README.md +481 -0
- package/docs/sn/README.md +481 -0
- package/docs/so/README.md +481 -0
- package/docs/sq/README.md +481 -0
- package/docs/sr/README.md +481 -0
- package/docs/st/README.md +481 -0
- package/docs/su/README.md +481 -0
- package/docs/sv/README.md +481 -0
- package/docs/sw/README.md +481 -0
- package/docs/ta/README.md +481 -0
- package/docs/te/README.md +481 -0
- package/docs/tg/README.md +481 -0
- package/docs/th/README.md +481 -0
- package/docs/tk/README.md +481 -0
- package/docs/tl/README.md +481 -0
- package/docs/tr/README.md +481 -0
- package/docs/tt/README.md +481 -0
- package/docs/ug/README.md +481 -0
- package/docs/uk/README.md +481 -0
- package/docs/ur/README.md +481 -0
- package/docs/uz/README.md +481 -0
- package/docs/vi/README.md +481 -0
- package/docs/xh/README.md +481 -0
- package/docs/yi/README.md +481 -0
- package/docs/yo/README.md +481 -0
- package/docs/zh/README.md +481 -0
- package/docs/zu/README.md +481 -0
- package/drivers/b2/index.js +25 -6
- package/hokey.json +16 -0
- package/index.js +7 -2
- package/package.json +1 -1
- package/test/api.spec.js +13 -9
- package/util/redis.js +2 -2
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
Mobiletto
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
Mobiletto nububiko bwa JavaScript ububiko, hamwe nubushake bwabakiriya-kuruhande rwibanga.
|
|
5
|
+
|
|
6
|
+
# Ibirimo
|
|
7
|
+
* [Kuki Mobiletto?](# Kuki-Mobiletto?)
|
|
8
|
+
* [Gutangira vuba](# Byihuse-gutangira)
|
|
9
|
+
* [Mobiletto CLI](# mobiletto-umukiriya)
|
|
10
|
+
* [Inkomoko](# Inkomoko)
|
|
11
|
+
* [Kwinjiza](# Kwinjiza)
|
|
12
|
+
* [Inkunga n'inkunga](# Inkunga-na-Inkunga)
|
|
13
|
+
* [Ikoreshwa ryibanze](# Shingiro-imikoreshereze)
|
|
14
|
+
* [Metadata](# Metadata)
|
|
15
|
+
* [Ubundi buryo bwo gutumiza mu mahanga](# Ubundi buryo-bwo gutumiza mu mahanga)
|
|
16
|
+
* [Cishing](# Cishing)
|
|
17
|
+
* [Indorerwamo](# Indorerwamo)
|
|
18
|
+
* [Gucisha mu mucyo](# Transparent-encryption)
|
|
19
|
+
* [Urufunguzo ruzunguruka](# Urufunguzo-ruzunguruka)
|
|
20
|
+
* [Imigaragarire yumushoferi](# Umushoferi-Imigaragarire)
|
|
21
|
+
* [Kwinjira](# Kwinjira)
|
|
22
|
+
|
|
23
|
+
# Soma ibi mu rundi rurimi
|
|
24
|
+
Iyi nyandiko README.md yarahinduwe, binyuze kuri [hokeylisation](https://github.com/cobbzilla/hokeylization), muri
|
|
25
|
+
** [ururimi rwose rushyigikiwe na Google Translate](https://cloud.google.com/translate/docs/ururimi)! **
|
|
26
|
+
|
|
27
|
+
Nzi neza ko bidatunganye, ariko nizere ko biruta ubusa!
|
|
28
|
+
|
|
29
|
+
[🇸🇦 Icyarabu](docs / ar / README.md)
|
|
30
|
+
[🇧🇩 Ikibengali](docs / bn / README.md)
|
|
31
|
+
[🇩🇪 Ikidage](docs / de / README.md)
|
|
32
|
+
[🇺🇸 Icyongereza](docs / en / README.md)
|
|
33
|
+
[🇪🇸 Icyesipanyoli](docs / es / README.md)
|
|
34
|
+
[🇫🇷 Igifaransa](docs / fr / README.md)
|
|
35
|
+
[🇹🇩 Hausa](docs / ha / README.md)
|
|
36
|
+
[🇮🇳 Hindi](docs / hi / README.md)
|
|
37
|
+
[🇮🇩 Indoneziya](docs / id / README.md)
|
|
38
|
+
[🇮🇹 Umutaliyani](docs / it / README.md)
|
|
39
|
+
[🇯🇵 Ikiyapani](docs / ja / README.md)
|
|
40
|
+
[🇰🇷 Igikoreya](docs / ko / README.md)
|
|
41
|
+
[🇮🇳 Maranthi](docs / mr / README.md)
|
|
42
|
+
[Ish Igipolonye](docs / pl / README.md)
|
|
43
|
+
[🇧🇷 Igiporutugali](docs / pt / README.md)
|
|
44
|
+
[🇷🇺 Ikirusiya](docs / ru / README.md)
|
|
45
|
+
[Wa Igiswahiri](docs / sw / README.md)
|
|
46
|
+
[🇵🇭 Tagalog](docs / tl / README.md)
|
|
47
|
+
[🇹🇷 Turukiya](docs / tr / README.md)
|
|
48
|
+
[🇵🇰 Urdu](docs / ur / README.md)
|
|
49
|
+
[🇻🇳 Abanya Viyetinamu](docs / vi / README.md)
|
|
50
|
+
[🇨🇳 Igishinwa](docs / zh / README.md)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
** [📚 ... Indimi zose ...](docs / README.md) **
|
|
54
|
+
----
|
|
55
|
+
|
|
56
|
+
### Hari ikibazo cyubu busobanuro bwa README?
|
|
57
|
+
Ubu busobanuro bwihariye bwumwimerere [README](https://github.com/cobbzilla/mobiletto/blob/master/README.md)
|
|
58
|
+
irashobora kuba ifite inenge - * gukosora biremewe cyane! * Nyamuneka ohereza [gukurura icyifuzo kuri GitHub](https://github.com/cobbzilla/mobiletto/pulls),
|
|
59
|
+
cyangwa niba utishimiye gukora ibyo, [fungura ikibazo](https://github.com/cobbzilla/mobiletto/issues)
|
|
60
|
+
|
|
61
|
+
Mugihe uremye ikibazo gishya cya GitHub kubyerekeye ubusobanuro, nyamuneka kora:
|
|
62
|
+
* shyiramo urupapuro rwa URL (kopi / komatanya uhereye kuri aderesi ya aderesi)
|
|
63
|
+
* shyiramo inyandiko nyayo itariyo (kopi / komatanya kuri mushakisha)
|
|
64
|
+
* nyamuneka sobanura ibitagenda neza - ubusobanuro ntabwo aribwo? imiterere yacitse kuburyo runaka?
|
|
65
|
+
* mutange igitekerezo cyo gusobanura neza, cyangwa uburyo inyandiko igomba guhindurwa neza
|
|
66
|
+
* ** Urakoze! **
|
|
67
|
+
|
|
68
|
+
## Kuki Mobiletto?
|
|
69
|
+
|
|
70
|
+
### Muraho neza umucuruzi ufunguye!
|
|
71
|
+
Abatanga ibicu bitandukanye bitandukanye bafite API zidahuye. Ndetse nabaharanira "S3 guhuza"
|
|
72
|
+
kugira imyitwarire idasanzwe.
|
|
73
|
+
|
|
74
|
+
Iyo uhisemo umucuruzi wububiko runaka kuri porogaramu yawe, niba wanditse kode kuri API yabo, porogaramu yawe
|
|
75
|
+
ubu biterwa na serivisi. Mugihe cyigihe kandi code ikarundanya, guhindura abacuruzi biba
|
|
76
|
+
bigenda bidashoboka. Murakaza neza ku isi ishimishije y'abacuruzi gufunga!
|
|
77
|
+
|
|
78
|
+
Mobiletto yagenewe gukemura iki kibazo. Ukoresheje porogaramu yawe kuri API ya mobiletto, urashobora byoroshye
|
|
79
|
+
hindura abatanga ububiko kandi umenye ko ububiko bwa porogaramu yawe izitwara kimwe.
|
|
80
|
+
|
|
81
|
+
### Ikizamini kinini
|
|
82
|
+
Abashoferi bose bapimwe imyitwarire imwe hamwe na 60+ ibizamini kuri buri shoferi.
|
|
83
|
+
Turagerageza abashoferi bose hamwe nibihuza byose:
|
|
84
|
+
* Encryption: byombi birashoboka kandi byahagaritswe
|
|
85
|
+
* Redis cache: byombi birashoboka kandi birahagarikwa
|
|
86
|
+
|
|
87
|
+
Ubu buryo buduha amahoro-yumutima ko mobiletto izitwara kimwe utitaye kumushoferi ukoresha,
|
|
88
|
+
kandi utitaye ko ushobora gukora cishing na / cyangwa encryption.
|
|
89
|
+
|
|
90
|
+
### Inkunga yabatwara
|
|
91
|
+
Abashoferi ba mobiletto y'ubu:
|
|
92
|
+
* `s3` : Amazon S3
|
|
93
|
+
* `b2` : Gusubira inyuma B2
|
|
94
|
+
* `local` : sisitemu yimikorere
|
|
95
|
+
|
|
96
|
+
* Umusanzu wo gushyigikira abatanga ibicu byinshi murakaza neza! *
|
|
97
|
+
|
|
98
|
+
## mobiletto-umukiriya
|
|
99
|
+
Mobiletto igenewe gukoreshwa nkisomero nizindi code ya JavaScript.
|
|
100
|
+
|
|
101
|
+
Gukorana na mobiletto kumurongo wumurongo, koresha [mobiletto-umukiriya](https://www.npmjs.com/package/mobiletto-cli)
|
|
102
|
+
|
|
103
|
+
## Inkomoko
|
|
104
|
+
* [mobiletto kuri GitHub](https://github.com/cobbzilla/mobiletto)
|
|
105
|
+
* [mobiletto kuri npm](https://www.npmjs.com/package/mobiletto)
|
|
106
|
+
|
|
107
|
+
## Inkunga ninkunga
|
|
108
|
+
Ndagerageza kuba umuhanga ufungura isoko yumwuga. Nakoraga
|
|
109
|
+
inganda za software imyaka myinshi, natangiye ibigo byatsinze ndabigurisha mubigo bya leta.
|
|
110
|
+
Mperutse kubura akazi, kandi rwose nta kindi gikorwa mfite ku murongo
|
|
111
|
+
|
|
112
|
+
Ngiye rero kugerageza kwandika software ifasha ndebe niba ibyo bikora
|
|
113
|
+
|
|
114
|
+
Niba ukunda gukoresha iyi software, ndagushimira cyane kubwa
|
|
115
|
+
ntoya [umusanzu wa buri kwezi ukoresheje Patreon](https://www.patreon.com/cobbzilla)
|
|
116
|
+
|
|
117
|
+
* Urakoze! *
|
|
118
|
+
|
|
119
|
+
## Kwinjiza
|
|
120
|
+
Shyiramo ukoresheje `npm` `yarn` . Birashoboka ko ushaka verisiyo ya `lite` itarimo byose
|
|
121
|
+
byahinduwe dosiye ya README:
|
|
122
|
+
|
|
123
|
+
npm install mobiletto-lite
|
|
124
|
+
yarn add mobiletto-lite
|
|
125
|
+
|
|
126
|
+
Niba rwose ushaka dosiye zo GUSOMA mururimi rwose, shyiramo verisiyo yuzuye:
|
|
127
|
+
|
|
128
|
+
npm install mobiletto
|
|
129
|
+
yarn add mobiletto
|
|
130
|
+
|
|
131
|
+
## Tangira vuba
|
|
132
|
+
Urugero rugufi ukoresheje mobiletto `s3` .
|
|
133
|
+
|
|
134
|
+
Iyi code yakora kimwe niba umushoferi yari `b2` `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
|
+
## Ikoreshwa ryibanze
|
|
165
|
+
Urugero runini cyane, rwerekana byinshi mubiranga byatanzwe:
|
|
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
|
+
Itegeko rya " `metadata` " risubiza metadata kubyerekeye kwinjiza dosiye imwe.
|
|
268
|
+
Mu buryo nk'ubwo, kugaruka agaciro kuva kuri `list` command ni umurongo wibintu bya metadata.
|
|
269
|
+
|
|
270
|
+
Ikintu cya metadata gisa nkiki:
|
|
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
|
+
Umutungo wa `type` urashobora kuba `file` , `dir` , `link` , cyangwa `special` .
|
|
281
|
+
|
|
282
|
+
Ukurikije ubwoko bwa shoferi, itegeko rya " `list` " ntirishobora gusubiza imirima yose. `type` `name`
|
|
283
|
+
igomba guhora ihari. Ibikurikira `metadata` itegeko rizasubiza ibintu byose biboneka.
|
|
284
|
+
|
|
285
|
+
## Ubundi buryo bwo gutumiza mu mahanga
|
|
286
|
+
Kuzana module yuzuye kandi ukoreshe imikorere ya `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
|
+
## Cishing
|
|
294
|
+
<a href="https://redis.io">Mobiletto</a> ikora neza hamwe na cache itukura.
|
|
295
|
+
|
|
296
|
+
Mobiletto izagerageza guhuza nurugero rwa redis kuri 127.0.0.1:6379
|
|
297
|
+
|
|
298
|
+
Urashobora guhisha kimwe muribi:
|
|
299
|
+
* Shiraho `MOBILETTO_REDIS_HOST` env var, mobiletto ihuza hano aho kubahost
|
|
300
|
+
* Shiraho `MOBILETTO_REDIS_PORT` env var, iki cyambu kizakoreshwa
|
|
301
|
+
|
|
302
|
+
Mobiletto izabika imfunguzo zayo zose za redis hamwe `_mobiletto__` . Urashobora guhindura ibi
|
|
303
|
+
mugushiraho `MOBILETTO_REDIS_PREFIX` env var.
|
|
304
|
+
|
|
305
|
+
Urashobora kandi gushiraho kuri buri guhuza cashe hamwe na `opts.redisConfig` ikintu:
|
|
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
|
+
### Ntushaka gufunga redis?
|
|
317
|
+
Kugirango uhagarike: pass `enabled: false` mubintu `opts.redisConfig` mugihe ushizeho isano yawe.
|
|
318
|
+
|
|
319
|
+
Nkuko byaganiriweho hepfo, guhagarika cishing bizagira ingaruka mbi kumikorere no gutanga ibyifuzo byinshi
|
|
320
|
+
kubika ukeneye rwose.
|
|
321
|
+
|
|
322
|
+
### Cishing ubuyobozi
|
|
323
|
+
** Ububiko bwabitswe **: gusoma / kwandika ububiko bwabitswe ni buhoro buhoro kurenza ibisanzwe,
|
|
324
|
+
ariko kugendagenda mububiko (ibyo ibintu bimwe bikora) bihenze rwose. Gukoresha cache
|
|
325
|
+
bizaguha imbaraga zingirakamaro.
|
|
326
|
+
|
|
327
|
+
Ubusanzwe cache ifite umutekano, ariko ntabwo ikora neza niba ufite byinshi byo kwandika / gukuraho ibikorwa.
|
|
328
|
+
Kwandika cyangwa gukuraho ibikorwa byose bitesha agaciro cache yose, kwemeza ko ibisomwa bizakurikiraho bizabona
|
|
329
|
+
impinduka ziheruka.
|
|
330
|
+
|
|
331
|
+
### ibikoresho bya CLI
|
|
332
|
+
Niba ukoresha igikoresho cya CLI nka [mobiletto-umukiriya](https://www.npmjs.com/package/mobiletto-cli),
|
|
333
|
+
uzashaka rwose redis cache ishoboye, nkuko imara igihe cyo gutabaza kwa `mo` .
|
|
334
|
+
|
|
335
|
+
## Indorerwamo
|
|
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
|
+
Itegeko rya `mirror` rikora kopi yigihe kimwe cya dosiye zose kuva mobiletto kugeza kurindi.
|
|
344
|
+
Ntabwo ikora inzira iyo ari yo yose yo kubungabunga indorerwamo mugihe. Ongera ukoreshe itegeko rya `mirror`
|
|
345
|
+
guhuza dosiye zose zabuze.
|
|
346
|
+
|
|
347
|
+
Garuka agaciro kiva muri `mirror` cyoroshye hamwe na compte yama dosiye menshi yagenze neza
|
|
348
|
+
indorerwamo nangahe dosiye zagize amakosa:
|
|
349
|
+
|
|
350
|
+
{
|
|
351
|
+
success: count-of-files-mirrored,
|
|
352
|
+
errors: count-of-files-with-errors
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
UMUBURO: Kwerekana amakuru manini yamakuru birashobora kugutwara igihe kandi bikaguka cyane
|
|
356
|
+
|
|
357
|
+
Hamwe na `mirror` call semantics birashobora rimwe na rimwe kwitiranya kumva uwariwe
|
|
358
|
+
umusomyi ninde wanditse. Tekereza nkibisobanuro byatanzwe: "ibumoso-mobiletto"
|
|
359
|
+
ni ikintu gihabwa (amakuru yindorerwamo yanditse), na "iburyo-mobiletto" (the
|
|
360
|
+
impaka kuri `mirror` method) nigiciro gihabwa (amakuru yindorerwamo arasomwa).
|
|
361
|
+
|
|
362
|
+
## Igenzura risobanutse
|
|
363
|
+
Gushoboza umukiriya kuruhande rwibanga:
|
|
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
|
+
Bigenda bite? Ububiko bwihariye "ububiko bwinjira" (dirent) ububiko (encrypted) bukurikirana dosiye zirimo
|
|
383
|
+
ububiko (bita dirent diregiteri).
|
|
384
|
+
* "Urutonde" itegeko risoma ububiko `list` yinjira, yandika buri nzira yanditse; hanyuma asubize metadata kuri buri dosiye
|
|
385
|
+
* `list` amategeko ntagikora cyane cyane kububiko bufite umubare munini wamadosiye
|
|
386
|
+
* Itegeko rya "andika" ryandika dosiye ya `write` muri diregiteri ya buri mubyeyi, inshuro nyinshi; hanyuma wandike dosiye
|
|
387
|
+
* `write` amategeko azashyiramo O (N) yanditse, hamwe na N = ubujyakuzimu mubuyobozi bukurikirana
|
|
388
|
+
* ' `remove` itegeko rikuraho dosiye ya dirent ijyanye, hamwe nababyeyi niba ari ubusa, byongeye; hanyuma ikuraho dosiye
|
|
389
|
+
* Kudasubiramo `remove` amategeko bizatera O (N) gusoma kandi birashoboka nkibisiba byinshi, hamwe na N = ubujyakuzimu mubuyobozi bukurikirana
|
|
390
|
+
* Gusubiramo `remove` amategeko kuri sisitemu nini kandi yimbitse ya dosiye irashobora kubahenze
|
|
391
|
+
|
|
392
|
+
Menya ko nubwo hamwe nabakiriya kuruhande rwibanga rushoboye, umwanzi ufite igaragara ryuzuye muri seriveri yawe-ibanga
|
|
393
|
+
ububiko, nubwo nta rufunguzo, burashobora kubona umubare wububiko hamwe nangahe dosiye ziri muri buri, hamwe na
|
|
394
|
+
imbaraga, kuvumbura bimwe cyangwa byose muburyo rusange bwububiko bukurikirana.
|
|
395
|
+
* Icyitonderwa: Koresha imiterere isa neza kugirango umutekano urusheho kuba mwiza. *
|
|
396
|
+
Umwanzi ntabwo yamenya amazina yububiko / dosiye keretse niba nabo bari bazi encryption yawe
|
|
397
|
+
urufunguzo cyangwa ubundi buryo bwatsinze neza ibanga. Bets zose zirahari noneho!
|
|
398
|
+
|
|
399
|
+
### Imikorere na cishing
|
|
400
|
+
Ibikorwa kububiko bwabitswe birashobora gutinda. Urutonde rusubirwamo no kuvanaho birashobora gutinda cyane.
|
|
401
|
+
Gufata ukoresheje redis bifasha cyane, ariko menya ko cache ihindurwamo inyandiko zose cyangwa ikuraho.
|
|
402
|
+
|
|
403
|
+
## Kuzenguruka urufunguzo
|
|
404
|
+
Kora mobiletto hamwe nurufunguzo rwawe rushya, hanyuma indorerwamo amakuru ashaje muri yo:
|
|
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
|
+
## Imigaragarire yabatwara
|
|
417
|
+
Umushoferi ni dosiye iyo ari yo yose ya JS yohereza hanze 'ububikoClient' imikorere hamwe nuyu mukono:
|
|
418
|
+
|
|
419
|
+
function storageClient (key, secret, opts)
|
|
420
|
+
|
|
421
|
+
* `key` : umugozi, urufunguzo rwa API ( `local` bubiko bwibanze)
|
|
422
|
+
* `secret` : umugozi, ibanga rya API yawe (rishobora gusibwa `local` shoferi)
|
|
423
|
+
* `opts` : ikintu, imitungo ni kuri buri shoferi:
|
|
424
|
+
* Kuri `local` , imitungo ya ' `fileMode` `dirMode` igena uburyo bushya bwo gukora dosiye nububiko byakozwe
|
|
425
|
+
* Kuri `s3` , umutungo wa ' `bucket` urakenewe. Ibintu bidahitamo ni:
|
|
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
|
+
Ikintu ububiko bwibikorwa bigaruka bigomba gusobanura iyi mirimo:
|
|
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
|
+
## Kwinjira
|
|
457
|
+
Mobiletto ikoresha isomero ryibiti bya [winston](https://www.npmjs.com/package/winston).
|
|
458
|
+
|
|
459
|
+
Ibiti ** bizaba ** birimo inzira za dosiye nubutumwa bwamakosa, ariko ntibizigera ** birimo urufunguzo, amabanga,
|
|
460
|
+
cyangwa andi makuru yose yo guhuza amakuru.
|
|
461
|
+
|
|
462
|
+
### Urwego Urwego
|
|
463
|
+
Koresha ibidukikije bya `MOBILETTO_LOG_LEVEL` kugirango ushireho urwego rwinjira, ukoresheje imwe
|
|
464
|
+
urwego rwa `npm` rwasobanuwe muri [https://www.npmjs.com/package/winston#logging-levels Igihugu (http:
|
|
465
|
+
|
|
466
|
+
Urwego rusanzwe ni `error` . Urwego rwinshinga cyane ni `silly` , nubwo kuri ubu mobiletto
|
|
467
|
+
ntabwo yinjira kurwego munsi `debug`
|
|
468
|
+
|
|
469
|
+
MOBILETTO_LOG_LEVEL=silly # maximum logs!
|
|
470
|
+
|
|
471
|
+
### Injira dosiye
|
|
472
|
+
Mburabuzi, uwandika yinjira kuri konsole. Kohereza ibiti muri dosiye, shiraho `MOBILETTO_LOG_FILE`
|
|
473
|
+
ibidukikije birahinduka. Iyo winjiye muri dosiye, ibiti ntibizongera kwandikwa kuri konsole.
|
|
474
|
+
|
|
475
|
+
MOBILETTO_LOG_FILE=/var/my_mobiletto_log
|
|
476
|
+
|
|
477
|
+
Kuzimya ibiti:
|
|
478
|
+
|
|
479
|
+
MOBILETTO_LOG_FILE=/dev/null
|
|
480
|
+
|
|
481
|
+
</pre>
|