mobiletto 1.2.1 → 2.0.1
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/lib/cjs/index.d.ts +2 -0
- package/lib/cjs/index.js +30 -0
- package/lib/cjs/package.json +16 -0
- package/lib/esm/index.d.ts +2 -0
- package/lib/esm/index.js +12 -0
- package/package.json +27 -13
- package/.babelrc +0 -5
- package/.eslintrc.js +0 -14
- package/docs/README.md +0 -113
- package/docs/af/README.md +0 -481
- package/docs/am/README.md +0 -481
- package/docs/ar/README.md +0 -481
- package/docs/az/README.md +0 -481
- package/docs/be/README.md +0 -481
- package/docs/bg/README.md +0 -481
- package/docs/bn/README.md +0 -481
- package/docs/bs/README.md +0 -481
- package/docs/ca/README.md +0 -481
- package/docs/ceb/README.md +0 -481
- package/docs/co/README.md +0 -481
- package/docs/cs/README.md +0 -481
- package/docs/cy/README.md +0 -481
- package/docs/da/README.md +0 -481
- package/docs/de/README.md +0 -481
- package/docs/el/README.md +0 -481
- package/docs/eo/README.md +0 -481
- package/docs/es/README.md +0 -481
- package/docs/et/README.md +0 -481
- package/docs/eu/README.md +0 -481
- package/docs/fa/README.md +0 -481
- package/docs/fi/README.md +0 -481
- package/docs/fr/README.md +0 -481
- package/docs/fy/README.md +0 -481
- package/docs/ga/README.md +0 -481
- package/docs/gd/README.md +0 -481
- package/docs/gl/README.md +0 -481
- package/docs/gu/README.md +0 -481
- package/docs/ha/README.md +0 -481
- package/docs/haw/README.md +0 -481
- package/docs/he/README.md +0 -481
- package/docs/hi/README.md +0 -481
- package/docs/hmn/README.md +0 -481
- package/docs/hr/README.md +0 -481
- package/docs/ht/README.md +0 -481
- package/docs/hu/README.md +0 -481
- package/docs/hy/README.md +0 -481
- package/docs/id/README.md +0 -481
- package/docs/ig/README.md +0 -481
- package/docs/is/README.md +0 -481
- package/docs/it/README.md +0 -481
- package/docs/iw/README.md +0 -481
- package/docs/ja/README.md +0 -481
- package/docs/jv/README.md +0 -481
- package/docs/ka/README.md +0 -481
- package/docs/kk/README.md +0 -481
- package/docs/km/README.md +0 -481
- package/docs/kn/README.md +0 -481
- package/docs/ko/README.md +0 -481
- package/docs/ku/README.md +0 -481
- package/docs/ky/README.md +0 -481
- package/docs/la/README.md +0 -481
- package/docs/lb/README.md +0 -481
- package/docs/lo/README.md +0 -481
- package/docs/lt/README.md +0 -481
- package/docs/lv/README.md +0 -481
- package/docs/mg/README.md +0 -481
- package/docs/mi/README.md +0 -481
- package/docs/mk/README.md +0 -481
- package/docs/ml/README.md +0 -481
- package/docs/mn/README.md +0 -481
- package/docs/mr/README.md +0 -481
- package/docs/ms/README.md +0 -481
- package/docs/mt/README.md +0 -481
- package/docs/my/README.md +0 -481
- package/docs/ne/README.md +0 -481
- package/docs/nl/README.md +0 -481
- package/docs/no/README.md +0 -481
- package/docs/ny/README.md +0 -481
- package/docs/or/README.md +0 -481
- package/docs/pa/README.md +0 -481
- package/docs/pl/README.md +0 -481
- package/docs/ps/README.md +0 -481
- package/docs/pt/README.md +0 -481
- package/docs/ro/README.md +0 -481
- package/docs/ru/README.md +0 -481
- package/docs/rw/README.md +0 -481
- package/docs/sd/README.md +0 -481
- package/docs/si/README.md +0 -481
- package/docs/sk/README.md +0 -481
- package/docs/sl/README.md +0 -481
- package/docs/sm/README.md +0 -481
- package/docs/sn/README.md +0 -481
- package/docs/so/README.md +0 -481
- package/docs/sq/README.md +0 -481
- package/docs/sr/README.md +0 -481
- package/docs/st/README.md +0 -481
- package/docs/su/README.md +0 -481
- package/docs/sv/README.md +0 -481
- package/docs/sw/README.md +0 -481
- package/docs/ta/README.md +0 -481
- package/docs/te/README.md +0 -481
- package/docs/tg/README.md +0 -481
- package/docs/th/README.md +0 -481
- package/docs/tk/README.md +0 -481
- package/docs/tl/README.md +0 -481
- package/docs/tr/README.md +0 -481
- package/docs/tt/README.md +0 -481
- package/docs/ug/README.md +0 -481
- package/docs/uk/README.md +0 -481
- package/docs/ur/README.md +0 -481
- package/docs/uz/README.md +0 -481
- package/docs/vi/README.md +0 -481
- package/docs/xh/README.md +0 -481
- package/docs/yi/README.md +0 -481
- package/docs/yo/README.md +0 -481
- package/docs/zh/README.md +0 -481
- package/docs/zu/README.md +0 -481
- package/drivers/b2/index.js +0 -451
- package/drivers/local/index.js +0 -315
- package/drivers/s3/index.js +0 -316
- package/hokey.json +0 -16
- package/index.js +0 -29
- package/test/api.spec.js +0 -512
- package/test/crypt.spec.js +0 -67
package/docs/ig/README.md
DELETED
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
Mobiletto
|
|
2
|
-
========
|
|
3
|
-
|
|
4
|
-
Mobiletto bụ oyi akwa abstraction nchekwa Javascript, nwere nhọrọ nzuzo nzuzo-n'akụkụ ndị ahịa.
|
|
5
|
-
|
|
6
|
-
# ọdịnaya
|
|
7
|
-
* [Gịnị kpatara Mobiletto?](#Gịnị kpatara-Mobiletto?)
|
|
8
|
-
* [Bido ngwa ngwa](#Bido ngwa ngwa)
|
|
9
|
-
* [Mobiletto CLI](#mobiletto-cli)
|
|
10
|
-
* [Isi Iyi](#Isi Iyi)
|
|
11
|
-
* [Nwụnye](#Nwụnye)
|
|
12
|
-
* [Nkwado na Ego](#Nkwado-na Ego)
|
|
13
|
-
* [Ojiji isi](#Basic-usage)
|
|
14
|
-
* [Metadata](#Metadata)
|
|
15
|
-
* [Ụdị mbubata ọzọ](#Ọzọ-import-style)
|
|
16
|
-
* [Caching](#Caching)
|
|
17
|
-
* [Mirroring](#Ego)
|
|
18
|
-
* [Transparent encryption](#Transparent-encryption)
|
|
19
|
-
* [Igodo ntụgharị](#Igodo-ntụgharị)
|
|
20
|
-
* [Ntụgharị ọkwọ ụgbọ ala](#Driver-interface)
|
|
21
|
-
* [Ịbanye](#Ịbanye)
|
|
22
|
-
|
|
23
|
-
# Gụọ nke a n'asụsụ ọzọ
|
|
24
|
-
Atụgharịrị asụsụ README.md akwụkwọ a, site na [hokeylization](https://github.com/cobbzilla/hokeylization), ka ọ bụrụ
|
|
25
|
-
**[Google Translate na-akwado asụsụ ọ bụla](https://cloud.google.com/translate/docs/languages)!**
|
|
26
|
-
|
|
27
|
-
Eji m n'aka na ọ zughị oke, mana enwere m olileanya na ọ ka mma karịa ihe ọ bụla!
|
|
28
|
-
|
|
29
|
-
[🇸🇦 Arabic](../ar/README.md)
|
|
30
|
-
[🇧🇩 Bengali](../bn/README.md)
|
|
31
|
-
[🇩🇪 German](../de/README.md)
|
|
32
|
-
[🇺🇸 Bekee](../en/README.md)
|
|
33
|
-
[🇪🇸 Spanish](../es/README.md)
|
|
34
|
-
[🇫🇷 French](../fr/README.md)
|
|
35
|
-
[🇹🇩 Hausa](../ha/README.md)
|
|
36
|
-
[🇮🇳 Hindi](../hi/README.md)
|
|
37
|
-
[🇮🇩 Indonesian](../id/README.md)
|
|
38
|
-
[🇮🇹 Italian](../it/README.md)
|
|
39
|
-
[🇯🇵 Japanese](../ja/README.md)
|
|
40
|
-
[🇰🇷 Korean](../ko/README.md)
|
|
41
|
-
[🇮🇳 Marathi](../mr/README.md)
|
|
42
|
-
[🇵🇱 Polish](../pl/README.md)
|
|
43
|
-
[🇧🇷 Portuguese](../pt/README.md)
|
|
44
|
-
[🇷🇺 Russian](../ru/README.md)
|
|
45
|
-
[🇰🇪 Swahili](../sw/README.md)
|
|
46
|
-
[🇵🇭 Tagalog](../tl/README.md)
|
|
47
|
-
[🇹🇷 Turkish](../tr/README.md)
|
|
48
|
-
[🇵🇰 Urdu](../ur/README.md)
|
|
49
|
-
[🇻🇳 Vietnamese](../vi/README.md)
|
|
50
|
-
[🇨🇳 Chinese](../zh/README.md)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
**[📚 ... Asụsụ niile ...](../README.md)**
|
|
54
|
-
----
|
|
55
|
-
|
|
56
|
-
### Enwere nsogbu na ntụgharị asụsụ README a?
|
|
57
|
-
Ntụgharị asụsụ nke izizi [README](https://github.com/cobbzilla/mobiletto/blob/master/README.md)
|
|
58
|
-
nwere ike inwe ntụpọ -- * A nabatara mgbazi!* Biko ziga arịrịọ [pull arịrịọ na GitHub](https://github.com/cobbzilla/mobiletto/pulls),
|
|
59
|
-
ma ọ bụ ọ bụrụ na ahụ adịghị gị mma ime nke ahụ, [mepee mbipụta](https://github.com/cobbzilla/mobiletto/issues)
|
|
60
|
-
|
|
61
|
-
Mgbe ị mepụtara mbipụta GitHub ọhụrụ gbasara ntụgharị asụsụ, biko mee:
|
|
62
|
-
* tinye URL ibe (detuo / mado site na ebe adreesị ihe nchọgharị)
|
|
63
|
-
* tinye ederede ezighi ezi (detuo / mado site na ihe nchọgharị)
|
|
64
|
-
* biko kọwaa ihe adịghị mma -- ntụgharị asụsụ ezighi ezi? Agbajiri usoro nhazi ahụ n'ụzọ ụfọdụ?
|
|
65
|
-
* jiri obiọma nye ntụnye nke ntụgharị asụsụ ka mma, ma ọ bụ ka esi ahazi ederede nke ọma
|
|
66
|
-
* **Daalụ!**
|
|
67
|
-
|
|
68
|
-
## Gịnị kpatara Mobiletto?
|
|
69
|
-
|
|
70
|
-
### Mkpọchi onye na-ere ihe ọma!
|
|
71
|
-
Ndị na-eweta nchekwa igwe ojii dị iche iche nwere API na-adakọghị ọnụ. Ọbụna ndị na-agbalị maka "S3 ndakọrịta"
|
|
72
|
-
nwere àgwà nzuzu.
|
|
73
|
-
|
|
74
|
-
Mgbe ịhọrọ otu onye na-ere nchekwa maka ngwa gị, ọ bụrụ na ị tinye koodu ozugbo na API ha, ngwa gị
|
|
75
|
-
ugbu a dabere na ọrụ ahụ. Ka oge na-aga na koodu na-agbakọta, ndị na-ere ahịa na-agbanwe agbanwe na-aghọ
|
|
76
|
-
na-esiwanye ike. Nnọọ n'ime ụwa egwu egwu nke mkpọchi ndị na-ere ahịa!
|
|
77
|
-
|
|
78
|
-
Emebere Mobiletto iji dozie nsogbu a. Site na itinye koodu gị ngwa na mobiletto's API, ị nwere ike mfe
|
|
79
|
-
gbanwee ndị na-eweta nchekwa wee mara na oyi akwa nchekwa ngwa gị ga-eme otu ihe.
|
|
80
|
-
|
|
81
|
-
### Nnwale sara mbara
|
|
82
|
-
A na-anwale ndị ọkwọ ụgbọ ala niile maka otu omume ahụ yana ule 60+ maka onye ọkwọ ụgbọ ala ọ bụla.
|
|
83
|
-
Anyị na-anwale ndị ọkwọ ụgbọala niile na ngwakọta ọ bụla:
|
|
84
|
-
* Izo ya ezo: ma enyere ma gbanyụọ
|
|
85
|
-
* Redis cache: enyere ma nwee nkwarụ
|
|
86
|
-
|
|
87
|
-
Usoro a na-enye anyị obi iru ala na mobiletto ga-eme otu ihe ahụ n'agbanyeghị onye ọkwọ ụgbọ ala ị na-eji,
|
|
88
|
-
na n'agbanyeghị ma ị na-enyere caching na/ma ọ bụ izo ya ezo.
|
|
89
|
-
|
|
90
|
-
### Nkwado ọkwọ ụgbọ ala
|
|
91
|
-
Ndị ọkwọ ụgbọala nchekwa Mobiletto dị ugbu a:
|
|
92
|
-
* `s3` : Amazon S3
|
|
93
|
-
* `b2` : Backblaze B2
|
|
94
|
-
* `local` : sistemụ faịlụ mpaghara
|
|
95
|
-
|
|
96
|
-
* A na-anabata onyinye iji kwado ndị na-eweta nchekwa igwe ojii!*
|
|
97
|
-
|
|
98
|
-
## mobiletto-cli
|
|
99
|
-
Ezubere Mobiletto ka ọ bụrụ ọba akwụkwọ site na koodu Javascript ndị ọzọ.
|
|
100
|
-
|
|
101
|
-
Iji rụọ ọrụ na mobiletto na ahịrị iwu, jiri [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)
|
|
102
|
-
|
|
103
|
-
## Isi mmalite
|
|
104
|
-
* [mobiletto na GitHub](https://github.com/cobbzilla/mobiletto)
|
|
105
|
-
* [mobiletto na npm](https://www.npmjs.com/package/mobiletto)
|
|
106
|
-
|
|
107
|
-
## Nkwado na ego
|
|
108
|
-
Ana m agbali ịbụ ọkachamara mmepe ngwanrọ mepere emepe. Anọ m na-arụ ọrụ
|
|
109
|
-
ụlọ ọrụ ngwanrọ ruo ọtụtụ afọ, amalitela m ụlọ ọrụ na-aga nke ọma ma ree ha ụlọ ọrụ ọha.
|
|
110
|
-
N’oge na-adịbeghị anya, a chụrụ m n’ọrụ, enweghịkwa m ọrụ ọ bụla e debere n’ahịrị
|
|
111
|
-
|
|
112
|
-
Ya mere, m ga-agbalị ide software na-enyere aka hụ ma ọ na-arụ ọrụ
|
|
113
|
-
|
|
114
|
-
Ọ bụrụ na ị na-enwe mmasị na iji nke a software, M ga-enwe nnọọ ekele maka ọbụna
|
|
115
|
-
kacha nta [onyinye kwa ọnwa site na Patreon](https://www.patreon.com/cobbzilla)
|
|
116
|
-
|
|
117
|
-
*Daalụ!*
|
|
118
|
-
|
|
119
|
-
## Nwụnye
|
|
120
|
-
Wụnye site na iji `npm` ma ọ bụ `yarn` . Ị nwere ike ịchọrọ ụdị `lite` nke na-agụnyeghị ihe niile
|
|
121
|
-
faịlụ README atụgharịrị:
|
|
122
|
-
|
|
123
|
-
npm install mobiletto-lite
|
|
124
|
-
yarn add mobiletto-lite
|
|
125
|
-
|
|
126
|
-
Ọ bụrụ n'ezie na ịchọrọ faịlụ README n'asụsụ ọ bụla, wụnye ụdị zuru ezu:
|
|
127
|
-
|
|
128
|
-
npm install mobiletto
|
|
129
|
-
yarn add mobiletto
|
|
130
|
-
|
|
131
|
-
## Mmalite ngwa ngwa
|
|
132
|
-
Ihe atụ dị mkpirikpi na-eji ọkwọ ụgbọala mobiletto `s3` .
|
|
133
|
-
|
|
134
|
-
Koodu a ga-eme otu ihe ahụ ma ọ bụrụ na ọkwọ ụgbọ ala bụ `b2` ma ọ bụ `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
|
-
## Ihe eji eme ihe
|
|
165
|
-
Ọmụmaatụ sara mbara karị, na-egosi ọtụtụ atụmatụ enyere:
|
|
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
|
-
Iwu `metadata` na-eweghachi metadata gbasara otu ntinye sistemụ faịlụ.
|
|
268
|
-
N'otu aka ahụ, uru nloghachi sitere na iwu `list` bụ ọtụtụ ihe metadata.
|
|
269
|
-
|
|
270
|
-
Ihe metadata dị ka nke a:
|
|
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
|
-
Ụdị `type` nwere ike ịbụ `file` ' , `dir` , `link` , ma ọ bụ `special` .
|
|
281
|
-
|
|
282
|
-
Dabere n'ụdị ọkwọ ụgbọ ala, iwu `list` nwere ike ọ gaghị eweghachi mpaghara niile. Njirimara `name` ' na `type`
|
|
283
|
-
kwesịrị ịdị mgbe niile. Iwu `metadata` na-esote ga-eweghachite akụrụngwa niile dị.
|
|
284
|
-
|
|
285
|
-
## Ụdị mbubata ọzọ
|
|
286
|
-
Bubata modul zuru oke wee jiri ọrụ `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 na-arụ ọrụ kacha mma na <a href="https://redis.io">redis</a> cache.
|
|
295
|
-
|
|
296
|
-
Mobiletto ga-anwa ijikọ na ihe atụ redis na 127.0.0.1:6379
|
|
297
|
-
|
|
298
|
-
Ị nwere ike ịkwụsị nke ọ bụla n'ime ndị a:
|
|
299
|
-
* Tọọ `MOBILETTO_REDIS_HOST` env var, mobiletto jikọọ ebe a kama localhost
|
|
300
|
-
* Tọọ `MOBILETTO_REDIS_PORT` env var, ọdụ ụgbọ mmiri a ga-eji
|
|
301
|
-
|
|
302
|
-
Mobiletto ga-eji prefix `_mobiletto__` igodo redis ya niile. Ị nwere ike ịgbanwe nke a
|
|
303
|
-
site na ịtọ `MOBILETTO_REDIS_PREFIX` env var.
|
|
304
|
-
|
|
305
|
-
Ị nwekwara ike iji ihe `opts.redisConfig` caching njikọ ọ bụla:
|
|
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
|
-
### Ịchọghị caching redis?
|
|
317
|
-
Iji gbanyụọ: nyefee `enabled: false` ' n'ime ihe `opts.redisConfig` gị mgbe ị mebere njikọ gị.
|
|
318
|
-
|
|
319
|
-
Dị ka a tụlere n'okpuru, ịkwụsị caching ga-enwe mmetụta ọjọọ na arụmọrụ ma weta arịrịọ ndị ọzọ
|
|
320
|
-
na nchekwa nke ị chọrọ n'ezie.
|
|
321
|
-
|
|
322
|
-
### ntụzịaka caching
|
|
323
|
-
** Nchekwa ezoro ezo ***: ịgụ / ide nchekwa ezoro ezo bụ naanị ntakịrị nwayọ karịa ka ọ dị,
|
|
324
|
-
mana ịgagharị gburugburu akwụkwọ ndekọ aha (nke ụfọdụ ihe na-eme) dị oke ọnụ. Iji redis cache
|
|
325
|
-
ga-enye gị nkwalite arụmọrụ dị ịrịba ama.
|
|
326
|
-
|
|
327
|
-
Cache ndabara adịghị mma, mana ọ naghị arụ ọrụ nke ọma ma ọ bụrụ na ị nwere ọtụtụ ọrụ ide/wepụ.
|
|
328
|
-
Edemede ma ọ bụ wepu ọrụ ọ bụla na-emebi cache niile, na-ahụ na agụ ga-esochi ga-ahụ ya
|
|
329
|
-
ọhụrụ mgbanwe.
|
|
330
|
-
|
|
331
|
-
### Ngwa CLI
|
|
332
|
-
Ọ bụrụ na ị na-eji ngwa CLI dị ka [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
|
|
333
|
-
ị ga-achọ ka agbanyere cache redis, ebe ọ na-aga n'ofe arịrịọ nke iwu `mo` .
|
|
334
|
-
|
|
335
|
-
## Ngosipụta
|
|
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
|
-
Iwu `mirror` na-arụ otu oge faịlụ niile site na otu mobiletto gaa na nke ọzọ.
|
|
344
|
-
Ọ naghị agba usoro ọ bụla iji nọgide na-enyo enyo ka oge na-aga. Gbaa iwu `mirror` ọzọ
|
|
345
|
-
imekọrịta faịlụ ọ bụla na-efu.
|
|
346
|
-
|
|
347
|
-
Uru nloghachi sitere na `mirror` bụ ihe dị mfe nwere ọnụọgụ maka faịlụ ole emere nke ọma
|
|
348
|
-
enyo enyo na faịlụ ole nwere mperi:
|
|
349
|
-
|
|
350
|
-
{
|
|
351
|
-
success: count-of-files-mirrored,
|
|
352
|
-
errors: count-of-files-with-errors
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
ỊDỌ AKA NA NTỊ: Igosipụta nnukwu data tent nwere ike na-ewe oge na bandwit-akpa ike
|
|
356
|
-
|
|
357
|
-
Site na semantics oku `mirror` ọ nwere ike bụrụ ihe mgbagwoju anya mgbe ụfọdụ ịghọta onye bụ
|
|
358
|
-
onye na-agụ na onye bụ onye edemede. Were ya dị ka nkwupụta ọrụ: "mobiletto aka ekpe"
|
|
359
|
-
bụ ihe a na-ekenye na (ederede enyo enyo), yana "mobiletto aka nri" (the
|
|
360
|
-
arụmụka na usoro `mirror` ) bụ uru a na-ekenye (a na-agụ data enyo).
|
|
361
|
-
|
|
362
|
-
## nzuzo nzuzo
|
|
363
|
-
Kwado ihe nzuzo n'akụkụ ndị ahịa nke ọma:
|
|
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
|
-
Kedu nke na-eme? Akwụkwọ ndekọ aha "ntinye ndekọ" dị iche (ezoro ezo) na-esochi ihe faịlụ dị na nke ahụ
|
|
383
|
-
akwụkwọ ndekọ aha (aka nke dient directory).
|
|
384
|
-
* Iwu `list` na-agụ faịlụ ntinye akwụkwọ ndekọ aha, mebie ụzọ ọ bụla edepụtara; wee weghachi metadata maka faịlụ ọ bụla
|
|
385
|
-
* `list` adịghị arụ ọrụ nke ọma, ọkachasị maka akwụkwọ ndekọ aha nwere nnukwu faịlụ
|
|
386
|
-
* Iwu `write` dere' na-ede faịlụ dị iche iche na ndekọ ndekọ aha nne na nna ọ bụla, na-emegharị ugboro ugboro; wee dee faịlụ ahụ
|
|
387
|
-
`write` ga-ebute O(N) dere, yana N = omimi n'ime usoro ndekọ aha.
|
|
388
|
-
* Iwu `remove` na-ewepu faịlụ dient kwekọrọ, yana nne na nna ya ọ bụrụ na ọ tọgbọrọ chakoo, na-emegharị ugboro ugboro; wee wepụ faịlụ ahụ
|
|
389
|
-
* Iwu `remove` na-anaghị emegharị emegharị ga-ebute O(N) agụ yana nwee ike ihichapụ, yana N = omimi n'ime usoro ndekọ aha.
|
|
390
|
-
* `remove` na-emegharị na sistemụ faịlụ buru ibu ma dị omimi nwere ike ịdị ọnụ
|
|
391
|
-
|
|
392
|
-
Rịba ama na ọbụlagodi na-enyere onye ahịa aka izo ya ezo, onye mmegide nwere ọhụhụ zuru oke n'ime akụkụ sava gị ezoro ezo.
|
|
393
|
-
nchekwa, ọbụlagodi na-enweghị igodo, ka nwere ike ịhụ ọnụọgụ akwụkwọ ndekọ aha na faịlụ ole dị na nke ọ bụla, yana ya
|
|
394
|
-
mgbalị ụfọdụ, chọpụta ụfọdụ ma ọ bụ ihe niile n'ozuzu nhazi nke usoro ndekọ aha.
|
|
395
|
-
*Rịba ama: Jiri usoro dị larịị maka nchekwa ka mma.*
|
|
396
|
-
Onye mmegide ahụ agaghị ama aha akwụkwọ ndekọ aha/faịlụ ma ọ bụrụ na ha makwara izo ya ezo
|
|
397
|
-
igodo ma ọ bụ ma ọ bụghị nke ọma gbawara ezoro ezo. Nzọ niile apụọla mgbe ahụ!
|
|
398
|
-
|
|
399
|
-
### Arụmọrụ na caching
|
|
400
|
-
Ọrụ na nchekwa ezoro ezo nwere ike ịdị nwayọ. Ndepụta ndetu na mwepụ nwere ike ịdị ngwa ngwa.
|
|
401
|
-
Caching site na redis na-enyere aka nke ukwuu, mana rịba ama na ebe nchekwa ahụ na-agbanye na ihe ọ bụla edere ma ọ bụ wepụ ya.
|
|
402
|
-
|
|
403
|
-
## ntụgharị igodo
|
|
404
|
-
Jiri igodo ọhụrụ gị mepụta mobiletto, wee gosipụta data ochie n'ime ya:
|
|
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 ọkwọ ụgbọ ala
|
|
417
|
-
Onye ọkwọ ụgbọ ala bụ faịlụ JS ọ bụla na-ebupụ ọrụ 'storageClient' na mbinye aka a:
|
|
418
|
-
|
|
419
|
-
function storageClient (key, secret, opts)
|
|
420
|
-
|
|
421
|
-
* `key` : eriri, igodo API gị (maka onye ọkwọ ụgbọ ala `local` nke a bụ ndekọ ntọala)
|
|
422
|
-
* `secret` : eriri, nzuzo API gị (enwere ike ịhapụ maka ọkwọ ụgbọ ala `local` mpaghara')
|
|
423
|
-
* `opts` : ihe, akụrụngwa bụ onye ọkwọ ụgbọ ala:
|
|
424
|
-
* Maka `local` , njirimara `fileMode` na `dirMode` na-ekpebi ka esi emepụta faịlụ na akwụkwọ ndekọ aha ọhụrụ.
|
|
425
|
-
* Maka `s3` , a chọrọ `bucket` . Njirimara nhọrọ bụ:
|
|
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
|
-
Ihe nchekwa ọrụ onye ahịa ga-eweghachi ga-akọwapụta ọrụ ndị a:
|
|
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
|
-
## Ịbanye
|
|
457
|
-
Mobiletto na-eji ọba akwụkwọ ndekọ [winston](https://www.npmjs.com/package/winston).
|
|
458
|
-
|
|
459
|
-
Ndekọ ** ga-enwe ụzọ faịlụ na ozi njehie, mana agaghị enwe igodo, nzuzo,
|
|
460
|
-
ma ọ bụ ozi nhazi njikọ ọ bụla ọzọ.
|
|
461
|
-
|
|
462
|
-
### ndekọ ọkwa
|
|
463
|
-
Jiri mgbanwe gburugburu `MOBILETTO_LOG_LEVEL` ka ịtọọ ọkwa ndekọ, na-eji otu
|
|
464
|
-
nke ọkwa `npm` akọwapụtara na [https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels)
|
|
465
|
-
|
|
466
|
-
Ọkwa ndabara bụ `error` . Ọkwa kacha ekwu okwu bụ `silly` , ọ bụ ezie na ugbu a mobiletto
|
|
467
|
-
adịghị abanye n'ọkwa dị n'okpuru `debug`
|
|
468
|
-
|
|
469
|
-
MOBILETTO_LOG_LEVEL=silly # maximum logs!
|
|
470
|
-
|
|
471
|
-
### Tinye faịlụ
|
|
472
|
-
Site na ndabara, onye na-edebanye aha na-edegara console. Iji zipu ndekọ na faịlụ, tọọ `MOBILETTO_LOG_FILE`
|
|
473
|
-
mgbanwe gburugburu ebe obibi. Mgbe ị na-abanye na faịlụ, agaghịzi ede ndekọ na njikwa.
|
|
474
|
-
|
|
475
|
-
MOBILETTO_LOG_FILE=/var/my_mobiletto_log
|
|
476
|
-
|
|
477
|
-
Iji gbanyụọ osisi:
|
|
478
|
-
|
|
479
|
-
MOBILETTO_LOG_FILE=/dev/null
|
|
480
|
-
|
|
481
|
-
</pre>
|