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/st/README.md
DELETED
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
Mobiletto
|
|
2
|
-
=========
|
|
3
|
-
|
|
4
|
-
Mobiletto ke karolo ea polokelo ea JavaScript, e nang le mokhoa oa boikhethelo o pepeneneng oa lehlakoreng la moreki.
|
|
5
|
-
|
|
6
|
-
# Litaba
|
|
7
|
-
* [Hobaneng Mobiletto?](#Hobaneng-Mobiletto?)
|
|
8
|
-
* [Qalo e potlakileng](#Qalo e potlakileng)
|
|
9
|
-
* [Mobiletto CLI](#mobiletto-cli)
|
|
10
|
-
* [Mohloli](#Mohloli)
|
|
11
|
-
* [Kenyo](#Kenyeletso)
|
|
12
|
-
* [Tšehetso le Lichelete](#Tšehetso-le-Lichelete)
|
|
13
|
-
* [Tsebeliso ea mantlha](#Tšebeliso ea mantlha)
|
|
14
|
-
* [Metadata](#Metadata)
|
|
15
|
-
* [Mokhoa o mong oa ho reka kantle ho naha](#Mokhoa-mokhoa o mong)
|
|
16
|
-
* [Caching](#Caching)
|
|
17
|
-
* [Ho etsa seipone](#Mirroring)
|
|
18
|
-
* [Ponaletso e hlakileng](#Ponaletso-encryption)
|
|
19
|
-
* [Ho potoloha ha senotlolo](#Ho potoloha)
|
|
20
|
-
* [Sebopeho sa mokhanni](#Sehokelo sa mokhanni)
|
|
21
|
-
* [Ho rengoa](#Ho rema)
|
|
22
|
-
|
|
23
|
-
# Bala sena ka puo e 'ngoe
|
|
24
|
-
Tokomane ena ea README.md e fetoletsoe, ka [hokeylization](https://github.com/cobbzilla/hokeylization), ho
|
|
25
|
-
**[puo e nngwe le e nngwe e tshehetswa ke Google Translate](https://cloud.google.com/translate/docs/languages)!**
|
|
26
|
-
|
|
27
|
-
Ke na le bonnete ba hore ha ea phethahala, empa ke ts'epa hore e betere ho feta letho!
|
|
28
|
-
|
|
29
|
-
[🇸🇦 Searabia](../ar/README.md)
|
|
30
|
-
[🇧🇩 Benghali](../bn/README.md)
|
|
31
|
-
[🇩🇪 Sejeremane](../de/README.md)
|
|
32
|
-
[🇺🇸 Senyesemane](../en/README.md)
|
|
33
|
-
[🇪🇸 Spanish](../es/README.md)
|
|
34
|
-
[🇫🇷 Sefora](../fr/README.md)
|
|
35
|
-
[🇹🇩 Hausa](../ha/README.md)
|
|
36
|
-
[🇮🇳 Sehindi](../hi/README.md)
|
|
37
|
-
[🇮🇩 Seindonesia](../id/README.md)
|
|
38
|
-
[🇮🇹 Setaliana](../it/README.md)
|
|
39
|
-
[🇯🇵 Sejapane](../ja/README.md)
|
|
40
|
-
[🇰🇷 Sekorea](../ko/README.md)
|
|
41
|
-
[🇮🇳 Marathi](../mr/README.md)
|
|
42
|
-
[🇵🇱 Sepolishe](../pl/README.md)
|
|
43
|
-
[🇧🇷 Sepotoketsi](../pt/README.md)
|
|
44
|
-
[🇷🇺 Serussia](../ru/README.md)
|
|
45
|
-
[🇰🇪 Seswahili](../sw/README.md)
|
|
46
|
-
[🇵🇭 Setagalog](../tl/README.md)
|
|
47
|
-
[🇹🇷 Seturkey](../tr/README.md)
|
|
48
|
-
[🇵🇰 Urdu](../ur/README.md)
|
|
49
|
-
[🇻🇳 Sevietnam](../vi/README.md)
|
|
50
|
-
[🇨🇳 Sechaena](../zh/README.md)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
**[📚 ... Lipuo Tsohle ...](../README.md)**
|
|
54
|
-
----
|
|
55
|
-
|
|
56
|
-
### Na ho na le bothata ka phetolelo ee ea README?
|
|
57
|
-
Phetolelo ena ea pele ea [README](https://github.com/cobbzilla/mobiletto/blob/master/README.md)
|
|
58
|
-
e kanna ea ba le bofokoli -- *litokiso li amohelehile!* Ka kopo, romella [ho hula kopo ho GitHub](https://github.com/cobbzilla/mobiletto/pulls),
|
|
59
|
-
kapa ha o sa phutholoha ho etsa joalo, [bula bothata](https://github.com/cobbzilla/mobiletto/issues)
|
|
60
|
-
|
|
61
|
-
Ha o theha taba e ncha ea GitHub mabapi le phetolelo, ka kopo etsa:
|
|
62
|
-
* kenyelletsa URL ea leqephe (kopi / beha ho tsoa bareng ea aterese ea sebatli)
|
|
63
|
-
* kenyelletsa mongolo o nepahetseng (kopi / beha ho tsoa ho sebatli)
|
|
64
|
-
* Ka kopo hlalosa se fosahetseng -- na phetolelo e fosahetse? na sebopeho se robehile ka tsela e itseng?
|
|
65
|
-
* ka mosa fana ka tlhahiso ea phetolelo e molemonyana, kapa hore na taba e ngotsoe joang ka tsela e nepahetseng
|
|
66
|
-
* **Kea leboha!**
|
|
67
|
-
|
|
68
|
-
## Hobaneng Mobiletto?
|
|
69
|
-
|
|
70
|
-
### Sala hantle ha barekisi ba notlela!
|
|
71
|
-
Bafani ba mefuta e fapaneng ea polokelo ea maru ba na le li-API tse sa lumellaneng. Esita le ba loanelang "S3 compatibility"
|
|
72
|
-
ba le boitšoaro bo sa tloaelehang.
|
|
73
|
-
|
|
74
|
-
Ha u khetha morekisi ea itseng oa polokelo bakeng sa sesebelisoa sa hau, haeba u khouta ka kotloloho ho API ea bona, sesebelisoa sa hau
|
|
75
|
-
jwale e itshetlehile ka tshebeletso eo. Ha nako e ntse e tsamaea le khoutu e ntse e bokellana, ho fetoha ha barekisi ho fetoha
|
|
76
|
-
e ntseng e sa kgonehe ho feta. Rea u amohela lefatšeng le monate la ho notlela ha barekisi!
|
|
77
|
-
|
|
78
|
-
Mobiletto e etselitsoe ho rarolla bothata bona. Ka ho khouta sesebelisoa sa hau ho mobiletto's API, u ka khona habonolo
|
|
79
|
-
fetola bafani ba polokelo 'me u tsebe hore sebaka sa polokelo ea sesebelisoa sa hau se tla sebetsa ka mokhoa o ts'oanang.
|
|
80
|
-
|
|
81
|
-
### Teko e batsi
|
|
82
|
-
Bakhanni bohle ba lekoa bakeng sa boitšoaro bo tšoanang ka liteko tse 60+ bakeng sa mokhanni ka mong.
|
|
83
|
-
Re leka bakhanni bohle ka motsoako o mong le o mong oa:
|
|
84
|
-
* Encryption: ka bobeli e nolofalitsoe ebile e holofalitsoe
|
|
85
|
-
* Redis cache: ka bobeli e nolofalitsoe ebile e holofetse
|
|
86
|
-
|
|
87
|
-
Mokhoa ona o re fa khotso ea kelello ea hore mobiletto e tla itšoara ka mokhoa o ts'oanang ho sa tsotellehe hore na u sebelisa mokhanni ofe,
|
|
88
|
-
le ho sa tsotelehe hore na o lumella caching le/kapa encryption.
|
|
89
|
-
|
|
90
|
-
### Tšehetso ea mokhanni
|
|
91
|
-
Bakhanni ba hajoale ba Mobiletto:
|
|
92
|
-
* `s3` : Amazon S3
|
|
93
|
-
* `b2` : Backblaze B2
|
|
94
|
-
* `local` : tsamaiso ea faele ea lehae
|
|
95
|
-
|
|
96
|
-
*Menehelo ea ho ts'ehetsa bafani ba bangata ba polokelo ea maru e amoheloa haholo!*
|
|
97
|
-
|
|
98
|
-
## mobiletto-cli
|
|
99
|
-
Mobiletto e reretsoe ho sebelisoa e le laebrari ka khoutu e 'ngoe ea JavaScript.
|
|
100
|
-
|
|
101
|
-
Ho sebetsa le mobiletto molaong oa taelo, sebelisa [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)
|
|
102
|
-
|
|
103
|
-
##Mohloli
|
|
104
|
-
* [mobiletto ho GitHub](https://github.com/cobbzilla/mobiletto)
|
|
105
|
-
* [mobiletto ho npm](https://www.npmjs.com/package/mobiletto)
|
|
106
|
-
|
|
107
|
-
## Tšehetso le Lichelete
|
|
108
|
-
Ke leka ho ba setsebi sa software ea open source software. Ke ntse ke sebetsa
|
|
109
|
-
indasteri ea software ka lilemo tse ngata, ke qalile lik'hamphani tse atlehileng mme ka li rekisetsa lik'hamphani tsa sechaba.
|
|
110
|
-
Haufinyane tjena ke lahlehetsoe ke mosebetsi, 'me ha ho na mosebetsi o mong oo ke o lokiselitseng
|
|
111
|
-
|
|
112
|
-
Kahoo ke tla leka ho ngola software e thusang mme ke bone hore na e ea sebetsa
|
|
113
|
-
|
|
114
|
-
Haeba u natefeloa ke ho sebelisa software ena, ke tla leboha haholo bakeng sa eona
|
|
115
|
-
e nyane [monehelo oa khoeli le khoeli ka Patreon](https://www.patreon.com/cobbzilla)
|
|
116
|
-
|
|
117
|
-
*Kea leboha!*
|
|
118
|
-
|
|
119
|
-
## Kemiso
|
|
120
|
-
Kenya o sebelisa `npm` kapa `yarn` . Mohlomong u batla mofuta oa `lite` o sa kenyelletseng kaofela
|
|
121
|
-
lifaele tsa README tse fetoletsoeng:
|
|
122
|
-
|
|
123
|
-
npm install mobiletto-lite
|
|
124
|
-
yarn add mobiletto-lite
|
|
125
|
-
|
|
126
|
-
Haeba u hlile u batla lifaele tsa README ka puo e 'ngoe le e' ngoe, kenya mofuta o felletseng:
|
|
127
|
-
|
|
128
|
-
npm install mobiletto
|
|
129
|
-
yarn add mobiletto
|
|
130
|
-
|
|
131
|
-
## Ho qala ka potlako
|
|
132
|
-
Mohlala o mokhuts'oane o sebelisang mokhanni oa mobiletto `s3` .
|
|
133
|
-
|
|
134
|
-
Khoutu ena e ne e tla sebetsa ka mokhoa o ts'oanang haeba mokhanni a le `b2` kapa `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
|
-
## Tšebeliso ea mantlha
|
|
165
|
-
Mohlala o pharaletseng haholoanyane, o bonts'ang boholo ba likarolo tse fanoeng:
|
|
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
|
-
Taelo ea `metadata` e khutlisetsa metadata mabapi le kenyo e le 'ngoe ea tsamaiso ea faele.
|
|
268
|
-
Ka mokhoa o ts'oanang, chelete e khutlisang ho tsoa ho taelo ea `list` ke lintho tse ngata tsa metadata.
|
|
269
|
-
|
|
270
|
-
Ntho ea metadata e shebahala tjena:
|
|
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
|
-
Thepa ea `type` e ka ba `file` , `dir` , `link` , kapa `special` .
|
|
281
|
-
|
|
282
|
-
Ho latela mofuta oa mokhanni, taelo ea `list` e kanna ea se khutlise likarolo tsohle. Thepa ea `name` le `type`
|
|
283
|
-
e lokela ho ba teng kamehla. Taelo e latelang ea `metadata` e tla khutlisa thepa eohle e teng.
|
|
284
|
-
|
|
285
|
-
## Mokhoa o mong oa ho kenya
|
|
286
|
-
Kenya mochini o hlophisitsoeng ka botlalo 'me u sebelise mosebetsi oa `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 e sebetsa hantle haholo ka cache ea <a href="https://redis.io">redis</a> .
|
|
295
|
-
|
|
296
|
-
Mobiletto e tla leka ho hokahana le mohlala oa redis ho 127.0.0.1:6379
|
|
297
|
-
|
|
298
|
-
O ka hlakola e 'ngoe ea tsena:
|
|
299
|
-
* Beha lebitso la `MOBILETTO_REDIS_HOST` env var, mobiletto hokela mona ho fapana le localhost
|
|
300
|
-
* Beha `MOBILETTO_REDIS_PORT` env var, boema-kepe bona bo tla sebelisoa
|
|
301
|
-
|
|
302
|
-
Mobiletto e tla boloka linotlolo tsohle tsa eona tsa redis ka `_mobiletto__` . O ka fetola sena
|
|
303
|
-
ka ho `MOBILETTO_REDIS_PREFIX` env var.
|
|
304
|
-
|
|
305
|
-
U ka boela ua seta caching ka khokahanyo ka ntho ea `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
|
-
### Ha u batle redis caching?
|
|
317
|
-
Ho tima: fetisa `enabled: false` ea hau ea `opts.redisConfig` ha u theha khokahano ea hau.
|
|
318
|
-
|
|
319
|
-
Joalo ka ha ho boletsoe ka tlase, ho thibela caching ho tla ba le phello e mpe ts'ebetsong mme ho hlahise likopo tse ngata
|
|
320
|
-
ho boloka seo u hlileng u se hlokang.
|
|
321
|
-
|
|
322
|
-
### Tataiso ea ho boloka
|
|
323
|
-
**polokelo e patiloeng**: polokelo e patiloeng ea ho bala/ho ngola e lieha ho feta e tloaelehileng,
|
|
324
|
-
empa ho pota-pota li-directory (tseo lintho tse ling li li etsang) ho bitsa chelete e ngata. Ho sebelisa cache ea redis
|
|
325
|
-
e tla u fa ntlafatso e kholo ea ts'ebetso.
|
|
326
|
-
|
|
327
|
-
Cache ea kamehla e bolokehile, empa ha e sebetse hantle haeba u na le mesebetsi e mengata ea ho ngola / ho tlosa.
|
|
328
|
-
Ts'ebetso efe kapa efe ea ho ngola kapa ea ho tlosa e etsa hore cache kaofela e se ke ea sebetsa, ho etsa bonnete ba hore lintho tse baloang tse latelang li tla bona
|
|
329
|
-
liphetoho tsa moraorao.
|
|
330
|
-
|
|
331
|
-
### CLI lisebelisoa
|
|
332
|
-
Haeba u sebelisa sesebelisoa sa CLI joalo ka [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
|
|
333
|
-
ka 'nete u tla batla hore cache ea redis e lumelloe, kaha e tšoarella ho pholletsa le likopo tsa taelo ea `mo` .
|
|
334
|
-
|
|
335
|
-
## Ho etsa seipone
|
|
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
|
-
Taelo ea `mirror` e etsa kopi ea nako e le 'ngoe ea lifaele tsohle ho tloha ho mobiletto e 'ngoe ho ea ho e' ngoe.
|
|
344
|
-
Ha e tsamaise mokhoa leha e le ofe oa ho boloka seipone ka nako. Etsa taelo ea `mirror` hape
|
|
345
|
-
ho amahanya difaele dife kapa dife tse sieo.
|
|
346
|
-
|
|
347
|
-
Theko ea ho khutlisa ho tsoa ho `mirror` ke ntho e bonolo e nang le li-counters tsa hore na ke lifaele tse kae tse atlehileng
|
|
348
|
-
seipone le hore na ke lifaele tse kae tse nang le liphoso:
|
|
349
|
-
|
|
350
|
-
{
|
|
351
|
-
success: count-of-files-mirrored,
|
|
352
|
-
errors: count-of-files-with-errors
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
TLHOKOMELISO: Ho bopa li-sete tse kholo tsa data ho ka nka nako haholo le ho nka sebaka sa marang-rang
|
|
356
|
-
|
|
357
|
-
Ka semantics ea `mirror` ka linako tse ling e ka ferekanya ho utloisisa hore na ke mang
|
|
358
|
-
mmadi le hore mongodi ke mang. Ak'u nahane joalo ka polelo ea kabelo: "mobileto ea letsoho le letšehali"
|
|
359
|
-
ke ntho e abetsoeng (data e entsoeng ka seipone), le "mobileto e letsohong le letona" (the
|
|
360
|
-
khang ea mokhoa oa `mirror` ) ke boleng bo abeloang (ho baloa data ea seipone).
|
|
361
|
-
|
|
362
|
-
## Encryption e hlakileng
|
|
363
|
-
Lumella mokhoa oa ho hlakoloa ka mokhoa o hlakileng oa lehlakoreng la moreki:
|
|
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
|
-
Ho etsahalang? Sebaka se arohaneng sa "directory entry" (dirent) directory (encrypted) se latela hore na lifaele li hokae
|
|
383
|
-
directory (eo hape e leng "dirent directory).
|
|
384
|
-
* Taelo ea `list` e bala lifaele tsa ho kenya li-directory, e hlakola tsela e 'ngoe le e 'ngoe e thathamisitsoeng; ebe o khutlisetsa metadata bakeng sa faele ka 'ngoe
|
|
385
|
-
* Litaelo tsa `list` ha li sebetse hantle, haholo bakeng sa li-directory tse nang le palo e kholo ea lifaele
|
|
386
|
-
* Taelo ea `write` e ngola lifaele tsa dirent bukeng e 'ngoe le e 'ngoe e fapaneng ea motsoali, ka ho pheta-pheta; ebe o ngola faele
|
|
387
|
-
* Litaelo tsa `write` li tla kenya O(N) ho ngola, ka N = botebo ba lethathamong la lihlopha.
|
|
388
|
-
* Taelo ea `remove` e tlosa faele e tsamaisanang le dirent, mme motsoali oa eona haeba e se na letho, ka ho pheta-pheta; ebe o tlosa faele
|
|
389
|
-
* Litaelo tse sa iphetang tsa `remove` li tla etsa hore O(N) e baloe 'me mohlomong e hlakoloe hangata, ka N = botebo ba lethathamong la lihlopha.
|
|
390
|
-
* `remove` tsa 'ho tlosa' tse pheta-phetoang ho li-file tse kholo le tse tebileng li ka bitsa chelete e ngata
|
|
391
|
-
|
|
392
|
-
Hlokomela hore leha encryption ea lehlakore la bareki e nolofalitsoe, mohanyetsi ea nang le ponahalo e felletseng ka lehlakoreng la hau la seva e patiloeng.
|
|
393
|
-
polokelo, leha e se na senotlolo, e ntse e khona ho bona palo eohle ea li-directory le hore na ho na le lifaele tse kae ho e 'ngoe le e 'ngoe, le ka
|
|
394
|
-
ka boiteko bo itseng, fumana tse ling kapa tsohle tsa sebopeho sa kakaretso sa lenane la lenane.
|
|
395
|
-
*Hlokomela: Sebelisa sebopeho se batlang se bataletse bakeng sa ts'ireletso e betere.
|
|
396
|
-
Mohanyetsi o ne a ke ke a tseba mabitso a li-directory / lifaele ntle le haeba a ne a tseba le encryption ea hau
|
|
397
|
-
key kapa o atlehile ho hlakola encryption. Libeche tsohle li felile ka nako eo!
|
|
398
|
-
|
|
399
|
-
### Tshebetso le caching
|
|
400
|
-
Ts'ebetso ea polokelo e patiloeng e ka tsamaea butle. Mananeo a iphetang le ho tlosa a ka lieha haholo.
|
|
401
|
-
Caching ka redis e thusa haholo, empa hlokomela hore cache e fetisoa ho eng kapa eng e ngotsoeng kapa e tlosoa.
|
|
402
|
-
|
|
403
|
-
## Phetoho ea bohlokoa
|
|
404
|
-
Theha mobiletto ka senotlolo sa hau se secha, ebe u sheba lintlha tsa khale ho eona:
|
|
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
|
-
## Sehokelo sa mokhanni
|
|
417
|
-
Mokhanni ke faele efe kapa efe ea JS e romellang mosebetsi oa 'storageClient' ka signature ena:
|
|
418
|
-
|
|
419
|
-
function storageClient (key, secret, opts)
|
|
420
|
-
|
|
421
|
-
* `key` : khoele, senotlolo sa hau sa API (bakeng sa mokhanni oa `local` ena ke buka ea motheo)
|
|
422
|
-
* `secret` : khoele, lekunutu la API ea hau (e ka siuoa bakeng sa mokhanni oa `local` )
|
|
423
|
-
* `opts` : ntho, thepa ke mokhanni ka mong:
|
|
424
|
-
* Bakeng sa `local` , thepa ea `fileMode` le `dirMode` e bontša hore na lifaele le litsamaiso tse ncha li etsoa joang.
|
|
425
|
-
* Bakeng sa `s3` , thepa ea `bucket` ea hlokahala. Lintho tseo u ka li khethang ke:
|
|
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
|
-
Ntho eo ts'ebetso ea storageClient e khutlisang e tlameha ho hlalosa mesebetsi ena:
|
|
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
|
-
## Ho rema lifate
|
|
457
|
-
Mobiletto e sebelisa [winston](https://www.npmjs.com/package/winston) laeborari ea ho rema lifate.
|
|
458
|
-
|
|
459
|
-
Li-log ** li tla ba le litsela tsa lifaele le melaetsa ea liphoso, empa ** ha ho mohla ** e nang le linotlolo, liphiri,
|
|
460
|
-
kapa tlhahisoleseding efe kapa efe e 'ngoe ea tlhophiso ea khokahano.
|
|
461
|
-
|
|
462
|
-
### Boemo ba marang-rang
|
|
463
|
-
Sebelisa sebopeho sa `MOBILETTO_LOG_LEVEL` ho seta boemo ba log, u sebelisa e le 'ngoe
|
|
464
|
-
ya maemo a `npm` a hlalositsweng ho [https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels)
|
|
465
|
-
|
|
466
|
-
Boemo ba kamehla ke `error` . Boemo ba leetsi haholo ke `silly` , leha hajoale mobiletto
|
|
467
|
-
ha e kene maemong a ka tlase ho `debug`
|
|
468
|
-
|
|
469
|
-
MOBILETTO_LOG_LEVEL=silly # maximum logs!
|
|
470
|
-
|
|
471
|
-
### Faele ea ho rekota
|
|
472
|
-
Ka ho sa feleng, ralithara o ngolla console. Ho romela litlaleho faeleng, beha `MOBILETTO_LOG_FILE`
|
|
473
|
-
tikoloho e fapaneng. Ha u kena faeleng, li-log ha li sa tla ngolloa ho console.
|
|
474
|
-
|
|
475
|
-
MOBILETTO_LOG_FILE=/var/my_mobiletto_log
|
|
476
|
-
|
|
477
|
-
Ho tima ho rema lifate:
|
|
478
|
-
|
|
479
|
-
MOBILETTO_LOG_FILE=/dev/null
|
|
480
|
-
|
|
481
|
-
</pre>
|