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
|
+
මොබයිල්ටෝ
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
Mobiletto යනු ජාවාස්ක්රිප්ට් ආචයන වියුක්ත ස්ථරයකි, විකල්ප විනිවිද පෙනෙන සේවාලාභී පාර්ශවීය සංකේතනයකි.
|
|
5
|
+
|
|
6
|
+
# අන්තර්ගතය
|
|
7
|
+
* [ඇයි Mobiletto?](#ඇයි-Mobiletto?)
|
|
8
|
+
* [ඉක්මන් ආරම්භය](#ඉක්මන්-ආරම්භය)
|
|
9
|
+
* [Mobiletto CLI](#mobiletto-cli)
|
|
10
|
+
* [මූලාශ්රය](#මූලාශ්රය)
|
|
11
|
+
* [ස්ථාපනය](#ස්ථාපනය)
|
|
12
|
+
* [සහාය සහ අරමුදල්](#සහාය සහ අරමුදල්)
|
|
13
|
+
* [මූලික භාවිතය](#මූලික-භාවිතය)
|
|
14
|
+
* [පාරදත්ත](#පාරදත්ත)
|
|
15
|
+
* [විකල්ප ආනයන විලාසය](#විකල්ප-ආනයන-විලාසය)
|
|
16
|
+
* [Caching](#Caching)
|
|
17
|
+
* [දර්පණය](#Mirroring)
|
|
18
|
+
* [විනිවිද පෙනෙන සංකේතනය](#විනිවිද පෙනෙන සංකේතනය)
|
|
19
|
+
* [යතුරු භ්රමණය](#යතුරු-භ්රමණය)
|
|
20
|
+
* [රියදුරු අතුරුමුහුණත](#ධාවක අතුරුමුහුණත)
|
|
21
|
+
* [ලොග් වීම](#ලොග් වීම)
|
|
22
|
+
|
|
23
|
+
# මෙය වෙනත් භාෂාවකින් කියවන්න
|
|
24
|
+
මෙම README.md ලේඛනය [hokeylization](https://github.com/cobbzilla/hokeylization) හරහා පරිවර්තනය කර ඇත.
|
|
25
|
+
**[Google Translate මඟින් සහාය දක්වන සෑම භාෂාවක්ම](https://cloud.google.com/translate/docs/languages)!**
|
|
26
|
+
|
|
27
|
+
එය පරිපූර්ණ නොවන බව මට විශ්වාසයි, නමුත් එය කිසිවකට වඩා හොඳ යැයි මම බලාපොරොත්තු වෙමි!
|
|
28
|
+
|
|
29
|
+
[🇸🇦 අරාබි](../ar/README.md)
|
|
30
|
+
[🇧🇩 බෙංගාලි](../bn/README.md)
|
|
31
|
+
[🇩🇪 ජර්මානු](../de/README.md)
|
|
32
|
+
[🇺🇸 ඉංග්රීසි](../en/README.md)
|
|
33
|
+
[🇪🇸 ස්පාඤ්ඤ](../es/README.md)
|
|
34
|
+
[🇫🇷 ප්රංශ](../fr/README.md)
|
|
35
|
+
[🇹🇩 Hausa](../ha/README.md)
|
|
36
|
+
[🇮🇳 හින්දි](../hi/README.md)
|
|
37
|
+
[🇮🇩 ඉන්දුනීසියානු](../id/README.md)
|
|
38
|
+
[🇮🇹 ඉතාලි](../it/README.md)
|
|
39
|
+
[🇯🇵 ජපන්](../ja/README.md)
|
|
40
|
+
[🇰🇷 කොරියානු](../ko/README.md)
|
|
41
|
+
[🇮🇳 මරන්ති](../mr/README.md)
|
|
42
|
+
[🇵🇱 පෝලන්ත](../pl/README.md)
|
|
43
|
+
[🇧🇷 පෘතුගීසි](../pt/README.md)
|
|
44
|
+
[🇷🇺 රුසියානු](../ru/README.md)
|
|
45
|
+
[🇰🇪 Swahili](../sw/README.md)
|
|
46
|
+
[🇵🇭 Tagalog](../tl/README.md)
|
|
47
|
+
[🇹🇷 තුර්කි](../tr/README.md)
|
|
48
|
+
[🇵🇰 උර්දු](../ur/README.md)
|
|
49
|
+
[🇻🇳 වියට්නාම](../vi/README.md)
|
|
50
|
+
[🇨🇳 චීන](../zh/README.md)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
**[📚 ... සියලුම භාෂා ...](../README.md)**
|
|
54
|
+
----
|
|
55
|
+
|
|
56
|
+
### README හි මෙම පරිවර්තනයේ ගැටලුවක් තිබේද?
|
|
57
|
+
මුල් [README] හි මෙම විශේෂිත පරිවර්තනය (https://github.com/cobbzilla/mobiletto/blob/master/README.md)
|
|
58
|
+
දෝෂ සහිත විය හැක -- *නිවැරදි කිරීම් ඉතා සාදරයෙන් පිළිගනිමු!* කරුණාකර [GitHub මත අදින්න ඉල්ලීමක්](https://github.com/cobbzilla/mobiletto/pulls),
|
|
59
|
+
හෝ ඔබට එය කිරීමට අපහසු නම්, [ගැටළුවක් විවෘත කරන්න](https://github.com/cobbzilla/mobiletto/issues)
|
|
60
|
+
|
|
61
|
+
ඔබ පරිවර්තනයක් පිළිබඳ නව GitHub ගැටලුවක් සාදන විට, කරුණාකර කරන්න:
|
|
62
|
+
* පිටු URL ඇතුළත් කරන්න (බ්රවුසර ලිපින තීරුවෙන් පිටපත් කරන්න/අලවන්න)
|
|
63
|
+
* වැරදි පෙළ ඇතුළත් කරන්න (බ්රවුසරයෙන් පිටපත් කරන්න/අලවන්න)
|
|
64
|
+
* කරුණාකර වැරදි දේ විස්තර කරන්න -- පරිවර්තනය වැරදිද? හැඩතල ගැන්වීම කෙසේ හෝ කැඩී තිබේද?
|
|
65
|
+
* වඩා හොඳ පරිවර්තනයක් පිළිබඳ යෝජනාවක් කාරුණිකව ඉදිරිපත් කරන්න, නැතහොත් පෙළ නිසි ලෙස හැඩසවිය යුතු ආකාරය
|
|
66
|
+
* **ඔබට ස්තුතියි!**
|
|
67
|
+
|
|
68
|
+
## ඇයි Mobiletto?
|
|
69
|
+
|
|
70
|
+
### ආයුබෝවන් වෙළෙන්දා අගුලු දැමීම!
|
|
71
|
+
විවිධ Cloud Storage සපයන්නන්ට නොගැලපෙන API ඇත. "S3 ගැළපුම" සඳහා උත්සාහ කරන අය පවා
|
|
72
|
+
මුග්ධ හැසිරීම් ඇත.
|
|
73
|
+
|
|
74
|
+
ඔබ ඔබේ යෙදුම සඳහා විශේෂිත ගබඩා වෙළෙන්දෙකු තෝරා ගන්නා විට, ඔබ ඔවුන්ගේ API, ඔබේ යෙදුම වෙත කෙලින්ම කේත කරන්නේ නම්
|
|
75
|
+
දැන් එම සේවාව මත රඳා පවතී. කාලය ගෙවී යන විට සහ කේතය එකතු වන විට, වෙළෙන්දන් වෙනස් වේ
|
|
76
|
+
වඩ වඩාත් දරාගත නොහැකි. විකුණුම්කරුවන්ගේ අගුලු දැමීමේ විනෝදජනක ලෝකයට සාදරයෙන් පිළිගනිමු!
|
|
77
|
+
|
|
78
|
+
Mobiletto මෙම ගැටළුව විසඳීම සඳහා නිර්මාණය කර ඇත. ඔබගේ යෙදුම mobiletto හි API වෙත කේතනය කිරීමෙන්, ඔබට පහසුවෙන් කළ හැක
|
|
79
|
+
ගබඩා සපයන්නන් වෙනස් කර ඔබගේ යෙදුමේ ගබඩා ස්තරය සමාන ලෙස හැසිරෙන බව දැන ගන්න.
|
|
80
|
+
|
|
81
|
+
### පුළුල් පරීක්ෂණ
|
|
82
|
+
සියලුම රියදුරන් එක් එක් රියදුරු සඳහා 60+ පරීක්ෂණ සමඟ සමාන හැසිරීම් සඳහා පරීක්ෂා කරනු ලැබේ.
|
|
83
|
+
අපි සෑම සංයෝජනයකින්ම සියලුම රියදුරන් පරීක්ෂා කරමු:
|
|
84
|
+
* සංකේතනය: සක්රීය සහ අක්රිය යන දෙකම
|
|
85
|
+
* Redis හැඹිලි: සක්රීය සහ අක්රීය යන දෙකම
|
|
86
|
+
|
|
87
|
+
මෙම ප්රවේශය අපට මනසේ සාමය ලබා දෙයි, ඔබ කුමන ධාවකයක් භාවිතා කළත් mobiletto එකම ලෙස හැසිරෙනු ඇත,
|
|
88
|
+
සහ ඔබ හැඹිලිගත කිරීම සහ/හෝ සංකේතනය සක්රීය කරන්නේද යන්න නොසලකා.
|
|
89
|
+
|
|
90
|
+
### රියදුරු සහාය
|
|
91
|
+
වත්මන් Mobiletto ගබඩා ධාවක:
|
|
92
|
+
* `s3` : Amazon S3
|
|
93
|
+
* `b2` : Backblaze B2
|
|
94
|
+
* `local` : දේශීය ගොනු පද්ධතිය
|
|
95
|
+
|
|
96
|
+
*තවත් Cloud Storage සපයන්නන්ට සහය වීමට දායක වීම ඉතා සාදරයෙන් පිළිගනිමු!*
|
|
97
|
+
|
|
98
|
+
## mobiletto-cli
|
|
99
|
+
Mobiletto වෙනත් JavaScript කේතයක් මගින් පුස්තකාලයක් ලෙස භාවිතා කිරීමට අදහස් කෙරේ.
|
|
100
|
+
|
|
101
|
+
විධාන රේඛාවේදී mobiletto සමඟ වැඩ කිරීමට, [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli) භාවිතා කරන්න
|
|
102
|
+
|
|
103
|
+
## මූලාශ්රය
|
|
104
|
+
* [GitHub හි ජංගම දුරකථන](https://github.com/cobbzilla/mobiletto)
|
|
105
|
+
* [mobiletto on npm](https://www.npmjs.com/package/mobiletto)
|
|
106
|
+
|
|
107
|
+
## ආධාර සහ අරමුදල්
|
|
108
|
+
මම වෘත්තීය විවෘත කේත මෘදුකාංග සංවර්ධකයෙකු වීමට උත්සාහ කරමි. මම වැඩ කරලා තියෙනවා
|
|
109
|
+
වසර ගණනාවක් තිස්සේ මෘදුකාංග කර්මාන්තය, මම සාර්ථක සමාගම් ආරම්භ කර ඒවා පොදු සමාගම්වලට විකුණා ඇත.
|
|
110
|
+
මෑතකදී මට මගේ රැකියාව අහිමි වූ අතර, මට වෙනත් වැඩ පෙළගැසී නොමැත
|
|
111
|
+
|
|
112
|
+
ඒ නිසා මම ප්රයෝජනවත් මෘදුකාංගයක් ලිවීමට උත්සාහ කර එය ක්රියාත්මක වේද බලන්න
|
|
113
|
+
|
|
114
|
+
ඔබ මෙම මෘදුකාංගය භාවිතා කිරීමෙන් සතුටක් ලබන්නේ නම්, ඒ සඳහා පවා මම බෙහෙවින් ස්තූතිවන්ත වෙමි
|
|
115
|
+
කුඩාම [Patreon හරහා මාසික දායකත්වය](https://www.patreon.com/cobbzilla)
|
|
116
|
+
|
|
117
|
+
*ඔබට ස්තුතියි!*
|
|
118
|
+
|
|
119
|
+
## ස්ථාපනය
|
|
120
|
+
`npm` හෝ `yarn` භාවිතයෙන් ස්ථාපනය කරන්න. ඔබට බොහෝ විට අවශ්ය වන්නේ සියල්ල ඇතුළත් නොවන `lite`
|
|
121
|
+
පරිවර්තනය කරන ලද README ගොනු:
|
|
122
|
+
|
|
123
|
+
npm install mobiletto-lite
|
|
124
|
+
yarn add mobiletto-lite
|
|
125
|
+
|
|
126
|
+
ඔබට සැබවින්ම සෑම භාෂාවකින්ම README ගොනු අවශ්ය නම්, සම්පූර්ණ අනුවාදය ස්ථාපනය කරන්න:
|
|
127
|
+
|
|
128
|
+
npm install mobiletto
|
|
129
|
+
yarn add mobiletto
|
|
130
|
+
|
|
131
|
+
## ඉක්මන් ආරම්භය
|
|
132
|
+
mobiletto `s3` ධාවකය භාවිතා කරන කෙටි උදාහරණයක්.
|
|
133
|
+
|
|
134
|
+
ධාවකය `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
|
+
## මූලික භාවිතය
|
|
165
|
+
ඉදිරිපත් කරන ලද බොහෝ විශේෂාංග පෙන්වන වඩාත් පුළුල් උදාහරණයක්:
|
|
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
|
+
## පාරදත්ත
|
|
267
|
+
`metadata` විධානය තනි ගොනු පද්ධති ප්රවේශයක් පිළිබඳ පාර-දත්ත ලබා දෙයි.
|
|
268
|
+
එලෙසම, `list` ලැබෙන ප්රතිලාභ අගය පාරදත්ත වස්තු අරාවකි.
|
|
269
|
+
|
|
270
|
+
පාර-දත්ත වස්තුවක් මේ ආකාරයට පෙනේ:
|
|
271
|
+
|
|
272
|
+
{
|
|
273
|
+
"name": "fully/qualified/path/to/file",
|
|
274
|
+
"type": "entry-type",
|
|
275
|
+
"size": size-in-bytes,
|
|
276
|
+
"ctime": creation-time-epoch-millis,
|
|
277
|
+
"mtime": modification-time-epoch-millis
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
`type` ගුණාංගය `file` , `dir` , `link` , හෝ `special` විය හැක.
|
|
281
|
+
|
|
282
|
+
ධාවක වර්ගය මත පදනම්ව, `list` විධානයක් මඟින් සියලුම ක්ෂේත්ර ආපසු ලබා නොදෙනු ඇත. `name` සහ `type` ගුණාංග
|
|
283
|
+
සැමවිටම සිටිය යුතුය. පසුකාලීන `metadata` විධානයක් මඟින් පවතින සියලුම ගුණාංග ලබා දෙනු ඇත.
|
|
284
|
+
|
|
285
|
+
## විකල්ප ආනයන විලාසය
|
|
286
|
+
සම්පූර්ණ විෂය පථය සහිත මොඩියුලය ආයාත කර 'සම්බන්ධ කරන්න `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
|
+
## හැඹිලිගත කිරීම
|
|
294
|
+
Mobiletto රෙඩිස් <a href="https://redis.io">හැඹිලියක්</a> සමඟ වඩාත් හොඳින් ක්රියා කරයි.
|
|
295
|
+
|
|
296
|
+
Mobiletto 127.0.0.1:6379 හි redis අවස්ථාවක් වෙත සම්බන්ධ වීමට උත්සාහ කරයි
|
|
297
|
+
|
|
298
|
+
ඔබට මේවායින් එකක් අභිබවා යා හැක:
|
|
299
|
+
* localhost වෙනුවට මෙහි සම්බන්ධ වීමට `MOBILETTO_REDIS_HOST` env var, mobiletto සකසන්න
|
|
300
|
+
* `MOBILETTO_REDIS_PORT` env var සකසන්න, මෙම තොට භාවිතා වේ
|
|
301
|
+
|
|
302
|
+
Mobiletto එහි සියලුම redis යතුරු `_mobiletto__` උපසර්ගය සමඟ ගබඩා කරනු ඇත. ඔබට මෙය වෙනස් කළ හැකිය
|
|
303
|
+
`MOBILETTO_REDIS_PREFIX` env var සැකසීමෙන්.
|
|
304
|
+
|
|
305
|
+
ඔබට `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
|
+
### redis caching අවශ්ය නොවේද?
|
|
317
|
+
අක්රිය කිරීමට: ඔබ ඔබේ සම්බන්ධතාවය ස්ථාපිත කරන විට ඔබේ `opts.redisConfig` වස්තුවේ `enabled: false` යන්න.
|
|
318
|
+
|
|
319
|
+
පහත සාකච්ඡා කර ඇති පරිදි, හැඹිලිගත කිරීම අක්රිය කිරීම කාර්ය සාධනය කෙරෙහි අහිතකර බලපෑමක් ඇති කරන අතර තවත් ඉල්ලීම් දරයි
|
|
320
|
+
ඔබට සැබවින්ම අවශ්ය ගබඩා කිරීමට.
|
|
321
|
+
|
|
322
|
+
### හැඹිලි මාර්ගෝපදේශය
|
|
323
|
+
**එන්ක්රිප්ටඩ් ආචයනය**: සංකේතාත්මක ආචයනය කියවීම/ලිවීම සාමාන්යයට වඩා ටිකක් මන්දගාමී වේ,
|
|
324
|
+
නමුත් නාමාවලි වටා සැරිසැරීම (සමහර දේවල් කරන) තරමක් මිල අධික වේ. redis cache එකක් භාවිතා කිරීම
|
|
325
|
+
ඔබට සැලකිය යුතු කාර්ය සාධනයක් ලබා දෙනු ඇත.
|
|
326
|
+
|
|
327
|
+
පෙරනිමි හැඹිලිය ආරක්ෂිතයි, නමුත් ඔබට ලිවීමේ/ඉවත් කිරීමේ මෙහෙයුම් බොහොමයක් තිබේ නම් හොඳින් ක්රියා නොකරයි.
|
|
328
|
+
ඕනෑම ලිවීමේ හෝ ඉවත් කිරීමේ මෙහෙයුමක් සම්පූර්ණ හැඹිලිය අවලංගු කරයි, පසුව කියවීම් දකින බව සහතික කරයි
|
|
329
|
+
නවතම වෙනස්කම්.
|
|
330
|
+
|
|
331
|
+
### CLI මෙවලම්
|
|
332
|
+
ඔබ [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli) වැනි CLI මෙවලමක් භාවිතා කරන්නේ නම්,
|
|
333
|
+
ඔබට අනිවාර්යයෙන්ම redis හැඹිලිය සක්රීය කිරීමට අවශ්ය වනු ඇත, එය `mo` විධානයේ ආයාචනා හරහා පවතිනු ඇත.
|
|
334
|
+
|
|
335
|
+
## දර්පණය
|
|
336
|
+
|
|
337
|
+
// Copy a local filesystem mobiletto to S3
|
|
338
|
+
s3.mirror(local)
|
|
339
|
+
|
|
340
|
+
// Mirror a local subdirectory from one mobiletto to an S3 mobiletto, with it's own subdirectory
|
|
341
|
+
local.mirror(s3, 'some/local-folder', 'some/s3-folder')
|
|
342
|
+
|
|
343
|
+
`mirror` විධානය මඟින් සියලුම ගොනු එක් ජංගම දුරකථනයකින් තවත් එකකට පිටපත් කිරීම සිදු කරයි.
|
|
344
|
+
කාලයත් සමඟ කැඩපත නඩත්තු කිරීම සඳහා එය කිසිදු ක්රියාවලියක් ක්රියාත්මක නොකරයි. නැවතත් `mirror` විධානය ක්රියාත්මක කරන්න
|
|
345
|
+
නැතිවූ ගොනු සමමුහුර්ත කිරීමට.
|
|
346
|
+
|
|
347
|
+
`mirror` වෙතින් ආපසු ලැබෙන අගය ගොනු කීයක් සාර්ථකව තිබේද යන්න සඳහා කවුන්ටර සහිත සරල වස්තුවකි
|
|
348
|
+
දර්පණය කර ඇති අතර ගොනු කීයක් දෝෂ තිබේද:
|
|
349
|
+
|
|
350
|
+
{
|
|
351
|
+
success: count-of-files-mirrored,
|
|
352
|
+
errors: count-of-files-with-errors
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
අවවාදයයි: විශාල දත්ත කට්ටල දර්පණය කිරීම ඉතා කාලය ගතවන සහ කලාප පළල-දැඩි විය හැක
|
|
356
|
+
|
|
357
|
+
`mirror` ඇමතුම් අර්ථ ශාස්ත්රය සමඟ එය කවුරුන්ද යන්න තේරුම් ගැනීම සමහර විට ව්යාකූල විය හැකිය
|
|
358
|
+
පාඨකයා සහ ලේඛකයා කවුද. එය පැවරුම් ප්රකාශයක් ලෙස සිතන්න: "වම් අත මොබයිටෝ"
|
|
359
|
+
(ලියන ලද දර්පණ දත්ත) වෙත පැවරී ඇති දෙය සහ "දකුණු අත මොබයිල්ටෝ" (ද
|
|
360
|
+
argument to the `mirror` method) යනු පවරනු ලබන අගයයි (දර්පණ දත්ත කියවනු ලැබේ).
|
|
361
|
+
|
|
362
|
+
## විනිවිද පෙනෙන සංකේතනය
|
|
363
|
+
විනිවිද පෙනෙන සේවාලාභී පාර්ශවීය සංකේතනය සබල කරන්න:
|
|
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
|
+
සිද්ධවන්නේ කුමක් ද? වෙනම "ඩිරෙක්ටරි ප්රවේශයක්" (ඩිරෙන්ට්) ඩිරෙක්ටරියක් (සංකේතනය කළ) එහි ඇති ගොනු මොනවාදැයි නිරීක්ෂණය කරයි.
|
|
383
|
+
නාමාවලිය (එනම් dirent නාමාවලිය).
|
|
384
|
+
* `list` විධානය මඟින් නාමාවලි ඇතුළත් ගොනු කියවයි, ලැයිස්තුගත කර ඇති සෑම මාර්ගයක්ම විකේතනය කරයි; එක් එක් ගොනුව සඳහා පාර-දත්ත ලබා දෙයි
|
|
385
|
+
* `list` විධාන වඩාත් අකාර්යක්ෂම වේ, විශේෂයෙන් ගොනු විශාල සංඛ්යාවක් සහිත නාමාවලි සඳහා
|
|
386
|
+
* `write` විධානය මඟින් එක් එක් මාපියන්ගේ dirent නාමාවලියෙහි, ප්රත්යාවර්තීව dirent ගොනු ලියයි; පසුව ගොනුව ලියයි
|
|
387
|
+
* `write` විධාන O(N) ලිවීම් සිදු කරනු ඇත, N = ඩිරෙක්ටරි ධුරාවලියේ ගැඹුර සමඟ
|
|
388
|
+
* `remove` ඉවත් කරන්න` විධානය අනුරූප dirent ගොනුව ඉවත් කරයි, සහ එහි මාපිය හිස් නම්, පුනරාවර්තන ලෙස; පසුව ගොනුව ඉවත් කරයි
|
|
389
|
+
* ප්රත්යාවර්තී නොවන `remove` විධාන O(N) කියවීම් සහ බොහෝ මකාදැමීම් සිදුවේ, නාමාවලි ධුරාවලියේ N = ගැඹුර සමඟ
|
|
390
|
+
* විශාල සහ ගැඹුරු ගොනු `remove` විධාන මිල අධික විය හැක
|
|
391
|
+
|
|
392
|
+
සේවාලාභියා-පාර්ශවීය සංකේතනය සක්රීය කර තිබියදීත්, ඔබේ සංකේතනය කළ සේවාදායක පැත්තට පූර්ණ දෘශ්යතාවක් ඇති විරුද්ධවාදියෙකු බව සලකන්න
|
|
393
|
+
ආචයනය, යතුර නොමැතිව වුවද, තවමත් මුළු නාමාවලි සංඛ්යාව සහ එක් එක් ගොනු කීයක් තිබේද, සහ සමඟ දැකිය හැක
|
|
394
|
+
යම් උත්සාහයක්, ඩිරෙක්ටරි ධුරාවලියේ සමස්ත ව්යුහයෙන් සමහරක් හෝ සියල්ල සොයා ගන්න.
|
|
395
|
+
*සටහන: වඩා හොඳ ආරක්ෂාවක් සඳහා සාපේක්ෂව පැතලි ව්යුහයක් භාවිතා කරන්න.*
|
|
396
|
+
විරුද්ධවාදියා ඔබේ සංකේතනය ද දන්නේ නම් මිස නාමාවලි/ගොනු වල නම් නොදනී.
|
|
397
|
+
යතුර හෝ වෙනත් ආකාරයකින් සංකේතනය සාර්ථකව බිඳ දමා ඇත. එවිට ඔට්ටු සියල්ල ක්රියාවිරහිතයි!
|
|
398
|
+
|
|
399
|
+
### කාර්ය සාධනය සහ හැඹිලිගත කිරීම
|
|
400
|
+
සංකේතාත්මක ආචයනය මත මෙහෙයුම් මන්දගාමී විය හැක. පුනරාවර්තන ලැයිස්තුගත කිරීම් සහ ඉවත් කිරීම් ඉතා මන්දගාමී විය හැක.
|
|
401
|
+
redis හරහා හැඹිලිගත කිරීම බෙහෙවින් උපකාරී වේ, නමුත් ඕනෑම ලිවීමක් හෝ ඉවත් කිරීමක් මත හැඹිලිය සෝදා හරින බව සලකන්න.
|
|
402
|
+
|
|
403
|
+
## යතුරු කැරකීම
|
|
404
|
+
ඔබගේ නව යතුර සමඟ mobiletto සාදන්න, ඉන්පසු පැරණි දත්ත එයට පිළිබිඹු කරන්න:
|
|
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
|
+
## රියදුරු අතුරු මුහුණත
|
|
417
|
+
ධාවකයක් යනු මෙම අත්සන සමඟ 'storageClient' ශ්රිතයක් අපනයනය කරන ඕනෑම JS ගොනුවකි:
|
|
418
|
+
|
|
419
|
+
function storageClient (key, secret, opts)
|
|
420
|
+
|
|
421
|
+
* `key` : තන්තුවක්, ඔබේ API යතුර ( `local` ධාවකය සඳහා මෙය මූලික නාමාවලියයි)
|
|
422
|
+
* `secret` : තන්තුවක්, ඔබේ API රහස ( `local` ධාවකය සඳහා මඟ හැරිය හැක)
|
|
423
|
+
* `opts` : වස්තුවක්, ගුණාංග එක් රියදුරෙකුට වේ:
|
|
424
|
+
* `local` සඳහා, `fileMode` සහ `dirMode` ගුණාංග නව නිර්මාණය කරන ගොනු සහ නාමාවලි නිර්මාණය කරන ආකාරය තීරණය කරයි
|
|
425
|
+
* `s3` සඳහා, `bucket` ගුණය අවශ්ය වේ. විකල්ප ගුණාංග වන්නේ:
|
|
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
|
+
ගබඩා සේවාලාභී ශ්රිතය ආපසු ලබා දෙන වස්තුව මෙම කාර්යයන් නිර්වචනය කළ යුතුය:
|
|
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
|
+
## ලොග් වීම
|
|
457
|
+
Mobiletto [winston](https://www.npmjs.com/package/winston) ලොග් කිරීමේ පුස්තකාලය භාවිතා කරයි.
|
|
458
|
+
|
|
459
|
+
ලඝු-සටහන් වල ** ගොනු මාර්ග සහ දෝෂ පණිවිඩ අඩංගු වේ, නමුත් ** කිසිදා** යතුරු, රහස්, අඩංගු නොවේ
|
|
460
|
+
හෝ වෙනත් සම්බන්ධතා වින්යාස තොරතුරු.
|
|
461
|
+
|
|
462
|
+
### ලොග් මට්ටම
|
|
463
|
+
එකක් භාවිතා කරමින් ලොග් මට්ටම සැකසීමට `MOBILETTO_LOG_LEVEL` පරිසර විචල්යය භාවිතා කරන්න
|
|
464
|
+
[https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels) හි අර්ථ දක්වා ඇති `npm` මට්ටම්
|
|
465
|
+
|
|
466
|
+
පෙරනිමි මට්ටම වන්නේ `error` . දැනට mobiletto වුවත්, වඩාත්ම වාචික මට්ටම `silly` වේ
|
|
467
|
+
`debug` වඩා අඩු මට්ටම් වල ලොග් නොවේ
|
|
468
|
+
|
|
469
|
+
MOBILETTO_LOG_LEVEL=silly # maximum logs!
|
|
470
|
+
|
|
471
|
+
### ලොග් ගොනුව
|
|
472
|
+
පෙරනිමියෙන්, ලොගර් කොන්සෝලය වෙත ලියයි. ගොනුවකට ලඝු-සටහන් යැවීමට, `MOBILETTO_LOG_FILE`
|
|
473
|
+
පරිසර විචල්යය. ගොනුවකට ලොග් වන විට, ලොග් තවදුරටත් කොන්සෝලය වෙත නොලියනු ඇත.
|
|
474
|
+
|
|
475
|
+
MOBILETTO_LOG_FILE=/var/my_mobiletto_log
|
|
476
|
+
|
|
477
|
+
ලොග් වීම අක්රිය කිරීමට:
|
|
478
|
+
|
|
479
|
+
MOBILETTO_LOG_FILE=/dev/null
|
|
480
|
+
|
|
481
|
+
</pre>
|