mobiletto 1.1.8 → 1.1.11
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 +56 -4
- package/docs/README.md +113 -0
- package/docs/af/README.md +455 -0
- package/docs/am/README.md +455 -0
- package/docs/ar/README.md +455 -0
- package/docs/az/README.md +455 -0
- package/docs/be/README.md +455 -0
- package/docs/bg/README.md +455 -0
- package/docs/bn/README.md +455 -0
- package/docs/bs/README.md +455 -0
- package/docs/ca/README.md +455 -0
- package/docs/ceb/README.md +455 -0
- package/docs/co/README.md +455 -0
- package/docs/cs/README.md +455 -0
- package/docs/cy/README.md +455 -0
- package/docs/da/README.md +455 -0
- package/docs/de/README.md +455 -0
- package/docs/el/README.md +455 -0
- package/docs/eo/README.md +455 -0
- package/docs/es/README.md +455 -0
- package/docs/et/README.md +455 -0
- package/docs/eu/README.md +455 -0
- package/docs/fa/README.md +455 -0
- package/docs/fi/README.md +455 -0
- package/docs/fr/README.md +455 -0
- package/docs/fy/README.md +455 -0
- package/docs/ga/README.md +455 -0
- package/docs/gd/README.md +455 -0
- package/docs/gl/README.md +455 -0
- package/docs/gu/README.md +455 -0
- package/docs/ha/README.md +455 -0
- package/docs/haw/README.md +455 -0
- package/docs/he/README.md +455 -0
- package/docs/hi/README.md +455 -0
- package/docs/hmn/README.md +455 -0
- package/docs/hr/README.md +455 -0
- package/docs/ht/README.md +455 -0
- package/docs/hu/README.md +455 -0
- package/docs/hy/README.md +455 -0
- package/docs/id/README.md +455 -0
- package/docs/ig/README.md +455 -0
- package/docs/is/README.md +455 -0
- package/docs/it/README.md +455 -0
- package/docs/iw/README.md +455 -0
- package/docs/ja/README.md +455 -0
- package/docs/jv/README.md +455 -0
- package/docs/ka/README.md +455 -0
- package/docs/kk/README.md +455 -0
- package/docs/km/README.md +455 -0
- package/docs/kn/README.md +455 -0
- package/docs/ko/README.md +455 -0
- package/docs/ku/README.md +455 -0
- package/docs/ky/README.md +455 -0
- package/docs/la/README.md +455 -0
- package/docs/lb/README.md +455 -0
- package/docs/lo/README.md +455 -0
- package/docs/lt/README.md +455 -0
- package/docs/lv/README.md +455 -0
- package/docs/mg/README.md +455 -0
- package/docs/mi/README.md +455 -0
- package/docs/mk/README.md +455 -0
- package/docs/ml/README.md +455 -0
- package/docs/mn/README.md +455 -0
- package/docs/mr/README.md +455 -0
- package/docs/ms/README.md +455 -0
- package/docs/mt/README.md +455 -0
- package/docs/my/README.md +455 -0
- package/docs/ne/README.md +455 -0
- package/docs/nl/README.md +455 -0
- package/docs/no/README.md +455 -0
- package/docs/ny/README.md +455 -0
- package/docs/or/README.md +455 -0
- package/docs/pa/README.md +455 -0
- package/docs/pl/README.md +455 -0
- package/docs/ps/README.md +455 -0
- package/docs/pt/README.md +455 -0
- package/docs/ro/README.md +455 -0
- package/docs/ru/README.md +455 -0
- package/docs/rw/README.md +455 -0
- package/docs/sd/README.md +455 -0
- package/docs/si/README.md +455 -0
- package/docs/sk/README.md +455 -0
- package/docs/sl/README.md +455 -0
- package/docs/sm/README.md +455 -0
- package/docs/sn/README.md +455 -0
- package/docs/so/README.md +455 -0
- package/docs/sq/README.md +455 -0
- package/docs/sr/README.md +455 -0
- package/docs/st/README.md +455 -0
- package/docs/su/README.md +455 -0
- package/docs/sv/README.md +455 -0
- package/docs/sw/README.md +455 -0
- package/docs/ta/README.md +455 -0
- package/docs/te/README.md +455 -0
- package/docs/tg/README.md +455 -0
- package/docs/th/README.md +455 -0
- package/docs/tk/README.md +455 -0
- package/docs/tl/README.md +455 -0
- package/docs/tr/README.md +455 -0
- package/docs/tt/README.md +455 -0
- package/docs/ug/README.md +455 -0
- package/docs/uk/README.md +455 -0
- package/docs/ur/README.md +455 -0
- package/docs/uz/README.md +455 -0
- package/docs/vi/README.md +455 -0
- package/docs/xh/README.md +455 -0
- package/docs/yi/README.md +455 -0
- package/docs/yo/README.md +455 -0
- package/docs/zh/README.md +455 -0
- package/docs/zu/README.md +455 -0
- package/drivers/b2/index.js +24 -6
- package/hokey.json +16 -0
- package/index.js +33 -17
- package/package.json +3 -2
- package/test/api.spec.js +319 -306
- package/util/logger.js +1 -1
- package/util/redis.js +1 -1
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
મોબાઈલટ્ટો
|
|
2
|
+
==========
|
|
3
|
+
|
|
4
|
+
Mobiletto એ JavaScript સ્ટોરેજ એબ્સ્ટ્રેક્શન લેયર છે, જેમાં વૈકલ્પિક પારદર્શક ક્લાયન્ટ-સાઇડ એન્ક્રિપ્શન છે.
|
|
5
|
+
|
|
6
|
+
# સામગ્રી
|
|
7
|
+
* [કેમ મોબાઈલટો?](#Why-Mobiletto?)
|
|
8
|
+
* [ઝડપી શરૂઆત](#ઝડપી-શરૂઆત)
|
|
9
|
+
* [Mobiletto CLI](#mobiletto-cli)
|
|
10
|
+
* [સ્રોત](#સ્રોત)
|
|
11
|
+
* [મૂળભૂત વપરાશ](#મૂળભૂત-ઉપયોગ)
|
|
12
|
+
* [મેટાડેટા](#મેટાડેટા)
|
|
13
|
+
* [વૈકલ્પિક આયાત શૈલી](#વૈકલ્પિક-આયાત-શૈલી)
|
|
14
|
+
* [કેશિંગ](#કેશિંગ)
|
|
15
|
+
* [મિરરિંગ](#મિરરિંગ)
|
|
16
|
+
* [પારદર્શક એન્ક્રિપ્શન](#પારદર્શક-એનક્રિપ્શન)
|
|
17
|
+
* [કી રોટેશન](#કી-રોટેશન)
|
|
18
|
+
* [ડ્રાઈવર ઈન્ટરફેસ](#ડ્રાઈવર ઈન્ટરફેસ)
|
|
19
|
+
* [લોગિંગ](#લોગિંગ)
|
|
20
|
+
|
|
21
|
+
# આને બીજી ભાષામાં વાંચો
|
|
22
|
+
આ README.md દસ્તાવેજનો અનુવાદ [hokeylization](https://github.com/cobbzilla/hokeylization) દ્વારા કરવામાં આવ્યો છે,
|
|
23
|
+
**[Google અનુવાદ દ્વારા સમર્થિત દરેક ભાષા](https://cloud.google.com/translate/docs/languages)!**
|
|
24
|
+
|
|
25
|
+
મને ખાતરી છે કે તે સંપૂર્ણ નથી, પરંતુ હું આશા રાખું છું કે તે કંઈ કરતાં વધુ સારું છે!
|
|
26
|
+
|
|
27
|
+
[🇸🇦 અરબી](../ar/README.md)
|
|
28
|
+
[🇧🇩 બંગાળી](../bn/README.md)
|
|
29
|
+
[🇩🇪 જર્મન](../de/README.md)
|
|
30
|
+
[🇺🇸 અંગ્રેજી](../en/README.md)
|
|
31
|
+
[🇪🇸 સ્પેનિશ](../es/README.md)
|
|
32
|
+
[🇫🇷 ફ્રેન્ચ](../fr/README.md)
|
|
33
|
+
[🇹🇩 હૌસા](../ha/README.md)
|
|
34
|
+
[🇮🇳 હિન્દી](../hi/README.md)
|
|
35
|
+
[🇮🇩 ઇન્ડોનેશિયન](../id/README.md)
|
|
36
|
+
[🇮🇹 ઇટાલિયન](../it/README.md)
|
|
37
|
+
[🇯🇵 જાપાનીઝ](../ja/README.md)
|
|
38
|
+
[🇰🇷 કોરિયન](../ko/README.md)
|
|
39
|
+
[🇮🇳 મરાંઠી](../mr/README.md)
|
|
40
|
+
[🇵🇱 પોલિશ](../pl/README.md)
|
|
41
|
+
[🇧🇷 પોર્ટુગીઝ](../pt/README.md)
|
|
42
|
+
[🇷🇺 રશિયન](../ru/README.md)
|
|
43
|
+
[🇰🇪 સ્વાહિલી](../sw/README.md)
|
|
44
|
+
[🇵🇭 ટાગાલોગ](../tl/README.md)
|
|
45
|
+
[🇹🇷 ટર્કિશ](../tr/README.md)
|
|
46
|
+
[🇵🇰 ઉર્દુ](../ur/README.md)
|
|
47
|
+
[🇻🇳 વિયેતનામીસ](../vi/README.md)
|
|
48
|
+
[🇨🇳 ચાઇનીઝ](../zh/README.md)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
**[📚 ... બધી ભાષાઓ ...](../README.md)**
|
|
52
|
+
----
|
|
53
|
+
|
|
54
|
+
### શું README ના આ અનુવાદમાં કોઈ સમસ્યા છે?
|
|
55
|
+
મૂળ [README](https://github.com/cobbzilla/mobiletto/blob/master/README.md) નો આ વિશિષ્ટ અનુવાદ
|
|
56
|
+
ખામી હોઈ શકે છે -- *સુધારાઓ ખૂબ આવકાર્ય છે!* કૃપા કરીને [GitHub પર પુલ વિનંતી](https://github.com/cobbzilla/mobiletto/pulls) મોકલો,
|
|
57
|
+
અથવા જો તમને તે કરવામાં આરામદાયક ન હોય, તો [સમસ્યા ખોલો](https://github.com/cobbzilla/mobiletto/issues)
|
|
58
|
+
|
|
59
|
+
જ્યારે તમે અનુવાદ વિશે નવો GitHub મુદ્દો બનાવો છો, ત્યારે કૃપા કરીને આ કરો:
|
|
60
|
+
* પૃષ્ઠ URL શામેલ કરો (બ્રાઉઝર સરનામાં બારમાંથી કૉપિ/પેસ્ટ કરો)
|
|
61
|
+
* ખોટો લખાણ શામેલ કરો (બ્રાઉઝરમાંથી કૉપિ/પેસ્ટ કરો)
|
|
62
|
+
* કૃપયા શું ખોટું છે તેનું વર્ણન કરો -- શું અનુવાદ ખોટો છે? શું ફોર્મેટિંગ કોઈક રીતે તૂટી ગયું છે?
|
|
63
|
+
* કૃપા કરીને વધુ સારા અનુવાદનું સૂચન આપો, અથવા ટેક્સ્ટ કેવી રીતે યોગ્ય રીતે ફોર્મેટ થવો જોઈએ
|
|
64
|
+
* **આભાર!**
|
|
65
|
+
|
|
66
|
+
## મોબાઈલટ્ટો શા માટે?
|
|
67
|
+
|
|
68
|
+
### ગુડબાય વેન્ડર લોક-ઇન!
|
|
69
|
+
વિવિધ ક્લાઉડ સ્ટોરેજ પ્રદાતાઓ પાસે અસંગત API છે. તે પણ જેઓ "S3 સુસંગતતા" માટે પ્રયત્ન કરે છે
|
|
70
|
+
રૂઢિચુસ્ત વર્તન ધરાવે છે.
|
|
71
|
+
|
|
72
|
+
જ્યારે તમે તમારી એપ્લિકેશન માટે કોઈ ચોક્કસ સ્ટોરેજ વિક્રેતા પસંદ કરો છો, જો તમે સીધા તેમના API પર કોડ કરો છો, તો તમારી એપ્લિકેશન
|
|
73
|
+
હવે તે સેવા પર નિર્ભર છે. જેમ જેમ સમય પસાર થાય છે અને કોડ એકઠા થાય છે તેમ, બદલાતા વિક્રેતાઓ બની જાય છે
|
|
74
|
+
વધુને વધુ અસમર્થ. વેન્ડર લોક-ઇનની મનોરંજક દુનિયામાં આપનું સ્વાગત છે!
|
|
75
|
+
|
|
76
|
+
Mobiletto આ સમસ્યાને ઉકેલવા માટે ડિઝાઇન કરવામાં આવી હતી. તમારી એપ્લિકેશનને mobiletto ના API પર કોડિંગ કરીને, તમે સરળતાથી કરી શકો છો
|
|
77
|
+
સ્ટોરેજ પ્રદાતાઓ બદલો અને જાણો કે તમારી એપ્લિકેશનનું સ્ટોરેજ સ્તર સમાન રીતે વર્તે છે.
|
|
78
|
+
|
|
79
|
+
### વ્યાપક પરીક્ષણ
|
|
80
|
+
દરેક ડ્રાઇવર માટે 60+ પરીક્ષણો સાથે સમાન વર્તન માટે બધા ડ્રાઇવરોનું પરીક્ષણ કરવામાં આવે છે.
|
|
81
|
+
અમે દરેક સંયોજન સાથે તમામ ડ્રાઇવરોનું પરીક્ષણ કરીએ છીએ:
|
|
82
|
+
* એન્ક્રિપ્શન: સક્ષમ અને અક્ષમ બંને
|
|
83
|
+
* રીડીસ કેશ: બંને સક્ષમ અને અક્ષમ
|
|
84
|
+
|
|
85
|
+
આ અભિગમ અમને મનની શાંતિ આપે છે કે તમે ગમે તે ડ્રાઇવરનો ઉપયોગ કરો છો, મોબાઇલટો એ જ વર્તન કરશે,
|
|
86
|
+
અને તમે કેશીંગ અને/અથવા એન્ક્રિપ્શન સક્ષમ કરો છો કે કેમ તે ધ્યાનમાં લીધા વગર.
|
|
87
|
+
|
|
88
|
+
### ડ્રાઈવર સપોર્ટ
|
|
89
|
+
વર્તમાન મોબાઇલટો સ્ટોરેજ ડ્રાઇવરો:
|
|
90
|
+
* `s3` : Amazon S3
|
|
91
|
+
* `b2` : બેકબ્લેઝ B2
|
|
92
|
+
* `local` : સ્થાનિક ફાઇલસિસ્ટમ
|
|
93
|
+
|
|
94
|
+
*વધુ ક્લાઉડ સ્ટોરેજ પ્રદાતાઓને સમર્થન આપવા માટે યોગદાન ખૂબ આવકાર્ય છે!*
|
|
95
|
+
|
|
96
|
+
## mobiletto-cli
|
|
97
|
+
Mobiletto અન્ય JavaScript કોડ દ્વારા લાઇબ્રેરી તરીકે ઉપયોગમાં લેવાનો છે.
|
|
98
|
+
|
|
99
|
+
કમાન્ડ-લાઇન પર mobiletto સાથે કામ કરવા માટે, [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli) નો ઉપયોગ કરો
|
|
100
|
+
|
|
101
|
+
## સ્ત્રોત
|
|
102
|
+
* [ગીથહબ પર મોબાઈલ](https://github.com/cobbzilla/mobiletto)
|
|
103
|
+
* [એનપીએમ પર મોબાઇલેટો](https://www.npmjs.com/package/mobiletto)
|
|
104
|
+
|
|
105
|
+
## ઝડપી શરૂઆત
|
|
106
|
+
Mobiletto `s3` ડ્રાઇવરનો ઉપયોગ કરવાનું ટૂંકું ઉદાહરણ.
|
|
107
|
+
|
|
108
|
+
જો ડ્રાઇવર `b2` અથવા `local` હોત તો આ કોડ સમાન ચાલશે.
|
|
109
|
+
|
|
110
|
+
const storage = require('mobiletto')
|
|
111
|
+
const bucket = await storage.connect('s3', aws_key, aws_secret, {bucket: 'bk'})
|
|
112
|
+
|
|
113
|
+
// list objects: returns array of metadata objects
|
|
114
|
+
const listing = await bucket.list()
|
|
115
|
+
const dirList = await bucket.list('some/dir/')
|
|
116
|
+
const everything = await bucket.list('', {recursive: true})
|
|
117
|
+
|
|
118
|
+
// write an entire file
|
|
119
|
+
let bytesWritten = await bucket.writeFile('some/path', someBufferOfData)
|
|
120
|
+
|
|
121
|
+
// write a file from a stream/generator
|
|
122
|
+
bytesWritten = await bucket.write('some/path', streamOrGenerator)
|
|
123
|
+
|
|
124
|
+
// read an entire file
|
|
125
|
+
// returns null if an exception would otherwise be thrown
|
|
126
|
+
const bufferOrNull = await bucket.safeReadFile('some/path')
|
|
127
|
+
|
|
128
|
+
// stream-read a file, passing data to callback
|
|
129
|
+
const bytesRead = await bucket.read('some/path', (chunk) => { ...do something with chunk... } )
|
|
130
|
+
|
|
131
|
+
// remove a file, returns the path removed
|
|
132
|
+
let removed = await bucket.remove('some/path') // removed is a string
|
|
133
|
+
|
|
134
|
+
// remove a directory, returns array of paths removed
|
|
135
|
+
removed = await bucket.remove('some/directory', {recursive: true}) // removed is now an array!
|
|
136
|
+
|
|
137
|
+
----
|
|
138
|
+
## મૂળભૂત ઉપયોગ
|
|
139
|
+
એક વધુ વ્યાપક ઉદાહરણ, ઓફર કરાયેલી મોટાભાગની સુવિધાઓ દર્શાવે છે:
|
|
140
|
+
|
|
141
|
+
const { mobiletto } = require('mobiletto')
|
|
142
|
+
|
|
143
|
+
// General usage
|
|
144
|
+
const api = await mobiletto(driverName, key, secret, opts)
|
|
145
|
+
|
|
146
|
+
// To use 'local' driver:
|
|
147
|
+
// * key: base directory
|
|
148
|
+
// * secret: ignored, can be null
|
|
149
|
+
// * opts object:
|
|
150
|
+
// * readOnly: optional, never change anything on the filesystem; default is false
|
|
151
|
+
// * fileMode: optional, permissions used when creating new files, default is 0600. can be string or integer
|
|
152
|
+
// * dirMode: optional, permissions used when creating new directories, default is 0700. can be string or integer
|
|
153
|
+
const local = await mobiletto('local', '/home/ubuntu/tmp', null, {fileMode: 0o0600, dirMode: '0700'})
|
|
154
|
+
|
|
155
|
+
// To use 's3' driver:
|
|
156
|
+
// * key: AWS Access Key ID
|
|
157
|
+
// * secret: AWS Secret Key
|
|
158
|
+
// * opts object:
|
|
159
|
+
// * readOnly: optional, never change anything on the bucket; default is false
|
|
160
|
+
// * bucket: required, name of the S3 bucket
|
|
161
|
+
// * region: optional, the AWS region to communicate with, default is us-east-1
|
|
162
|
+
// * prefix: optional, all read/writes within the S3 bucket will be under this prefix
|
|
163
|
+
// * delimiter: optional, directory delimiter, default is '/' (note: always '/' when encryption is enabled)
|
|
164
|
+
const s3 = await mobiletto('s3', aws_key, aws_secret, {bucket: 'bk', region: 'us-east-1'})
|
|
165
|
+
|
|
166
|
+
// To use 'b2' driver:
|
|
167
|
+
// * key: Backblaze Key ID
|
|
168
|
+
// * secret: Backblaze Application Key
|
|
169
|
+
// * opts object:
|
|
170
|
+
// * readOnly: optional, never change anything on the bucket; default is false
|
|
171
|
+
// * bucket: required, the ID (**not the name**) of the B2 bucket
|
|
172
|
+
// * prefix: optional, all read/writes within the B2 bucket will be under this prefix
|
|
173
|
+
// * delimiter: optional, directory delimiter, default is '/' (note: always '/' when encryption is enabled)
|
|
174
|
+
// * partSize: optional, large files will be split into chunks of this size when uploading
|
|
175
|
+
const b3 = await mobiletto('b2', b2_key_id, b2_app_key, {bucket: 'bk', partSize: 10000000})
|
|
176
|
+
|
|
177
|
+
// List files
|
|
178
|
+
api.list() // --> returns an array of metadata objects
|
|
179
|
+
|
|
180
|
+
// List files recursively
|
|
181
|
+
api.list({ recursive: true })
|
|
182
|
+
|
|
183
|
+
// List files in a directory
|
|
184
|
+
const path = 'some/path'
|
|
185
|
+
api.list(path)
|
|
186
|
+
api.list(path, { recursive: true }) // also supports recursive flag
|
|
187
|
+
|
|
188
|
+
// Visit files in a directory -- visitor function must be async
|
|
189
|
+
api.list(path, { visitor: myAsyncFunc })
|
|
190
|
+
api.list(path, { visitor: myAsyncFunc, recursive: true })
|
|
191
|
+
|
|
192
|
+
// The `list` method throws MobilettoNotFoundError if the path does not exist
|
|
193
|
+
// When you call `safeList` on a non-existent path, it returns an empty array
|
|
194
|
+
api.safeList('/path/that/does/not/exist') // returns []
|
|
195
|
+
|
|
196
|
+
// Read metadata for a file
|
|
197
|
+
api.metadata(path) // returns metadata object
|
|
198
|
+
|
|
199
|
+
// The `metadata` method throws MobilettoNotFoundError if the path does not exist
|
|
200
|
+
// When you call `safeMetadata` on a non-existent path, it returns null
|
|
201
|
+
api.safeMetadata('/tmp/does_not_exist') // returns null
|
|
202
|
+
|
|
203
|
+
// Read a file
|
|
204
|
+
// Provide a callback that writes the data someplace
|
|
205
|
+
const callback = (chunk) => { ... write chunk somewhere ... }
|
|
206
|
+
api.read(path, callback) // returns count of bytes read
|
|
207
|
+
|
|
208
|
+
// Read an entire file at once
|
|
209
|
+
const data = await api.readFile(path) // returns a byte Buffer of the file contents
|
|
210
|
+
|
|
211
|
+
// Read an entire file at once
|
|
212
|
+
// returns null if an exception would otherwise be thrown
|
|
213
|
+
const bufferOrNull = await bucket.safeReadFile('some/path')
|
|
214
|
+
|
|
215
|
+
// Write a file
|
|
216
|
+
// Provide a generator function that yields chunks of data
|
|
217
|
+
const generator = function* () {
|
|
218
|
+
while ( ... more-data-to-return ... ) {
|
|
219
|
+
data = ... load-data ...
|
|
220
|
+
yield data
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
local.api(path, generator) // returns count of bytes written
|
|
224
|
+
|
|
225
|
+
// Write an entire file at once (convenience method)
|
|
226
|
+
await api.writeFile(path, bufferOrString) // returns count of bytes written
|
|
227
|
+
|
|
228
|
+
// Delete a file
|
|
229
|
+
// Quiet param is optional (default false), when set errors will not be thrown if the path does not exist
|
|
230
|
+
// Always returns a value or throws an error.
|
|
231
|
+
// Return value may be a single string of the file removed, or an array of all files removed (driver-dependent)
|
|
232
|
+
const quiet = true
|
|
233
|
+
api.remove(path, {quiet}) // returns single path removed
|
|
234
|
+
|
|
235
|
+
// Recursively delete a directory and do it quietly (do not report errors)
|
|
236
|
+
const recursive = true
|
|
237
|
+
const quiet = true
|
|
238
|
+
api.remove(path, {recursive, quiet}) // returns array of paths removed
|
|
239
|
+
|
|
240
|
+
## મેટાડેટા
|
|
241
|
+
`metadata` આદેશ સિંગલ ફાઇલસિસ્ટમ એન્ટ્રી વિશે મેટાડેટા પરત કરે છે.
|
|
242
|
+
તેવી જ રીતે, `list` આદેશમાંથી વળતર મૂલ્ય એ મેટાડેટા ઑબ્જેક્ટ્સની એરે છે.
|
|
243
|
+
|
|
244
|
+
મેટાડેટા ઑબ્જેક્ટ આના જેવો દેખાય છે:
|
|
245
|
+
|
|
246
|
+
{
|
|
247
|
+
"name": "fully/qualified/path/to/file",
|
|
248
|
+
"type": "entry-type",
|
|
249
|
+
"size": size-in-bytes,
|
|
250
|
+
"ctime": creation-time-epoch-millis,
|
|
251
|
+
"mtime": modification-time-epoch-millis
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
`type` ટાઇપ` ગુણધર્મ `file` `dir` , `link` અથવા `special` છે.
|
|
255
|
+
|
|
256
|
+
ડ્રાઇવરના પ્રકાર પર આધાર રાખીને, `list` આદેશ કદાચ તમામ ક્ષેત્રો પરત કરી શકશે નહીં. `name` અને `type` પ્રકાર` ગુણધર્મો
|
|
257
|
+
હંમેશા હાજર રહેવું જોઈએ. અનુગામી `metadata` આદેશ તમામ ઉપલબ્ધ ગુણધર્મો પરત કરશે.
|
|
258
|
+
|
|
259
|
+
## વૈકલ્પિક આયાત શૈલી
|
|
260
|
+
સંપૂર્ણ-સ્કોપવાળા મોડ્યુલને આયાત કરો અને `connect` ફંક્શનનો ઉપયોગ કરો:
|
|
261
|
+
|
|
262
|
+
const storage = require('mobiletto')
|
|
263
|
+
const opts = {bucket: 'bk', region: 'us-east-1'}
|
|
264
|
+
const s3 = await storage.connect('s3', aws_key, aws_secret, opts)
|
|
265
|
+
const objectData = await s3.readFile('some/path')
|
|
266
|
+
|
|
267
|
+
## કેશીંગ
|
|
268
|
+
<a href="https://redis.io">Mobiletto</a> રેડિસ કેશ સાથે શ્રેષ્ઠ કામ કરે છે.
|
|
269
|
+
|
|
270
|
+
Mobiletto 127.0.0.1:6379 પર redis ઇન્સ્ટન્સ સાથે કનેક્ટ કરવાનો પ્રયાસ કરશે
|
|
271
|
+
|
|
272
|
+
તમે આમાંથી કોઈપણ પર ફરીથી લખી શકો છો:
|
|
273
|
+
* `MOBILETTO_REDIS_HOST` env var સેટ કરો, mobiletto અહીં લોકલહોસ્ટને બદલે કનેક્ટ કરો
|
|
274
|
+
* `MOBILETTO_REDIS_PORT` env var સેટ કરો, આ પોર્ટનો ઉપયોગ કરવામાં આવશે
|
|
275
|
+
|
|
276
|
+
Mobiletto તેની તમામ redis કીને `_mobiletto__` ઉપસર્ગ સાથે સંગ્રહિત કરશે. તમે આ બદલી શકો છો
|
|
277
|
+
`MOBILETTO_REDIS_PREFIX` env var સેટ કરીને.
|
|
278
|
+
|
|
279
|
+
તમે `opts.redisConfig` ઑબ્જેક્ટ સાથે પ્રતિ-કનેક્શન કેશીંગ પણ સેટ કરી શકો છો:
|
|
280
|
+
|
|
281
|
+
const redisConfig = {
|
|
282
|
+
enabled: true, // optional, default is true. if false other props are ignored
|
|
283
|
+
host: '127.0.0.1',
|
|
284
|
+
port: 6379,
|
|
285
|
+
prefix: '_mobiletto__'
|
|
286
|
+
}
|
|
287
|
+
const opts = { redisConfig, bucket: 'bk', region: 'us-east-1' }
|
|
288
|
+
const s3 = await storage.connect('s3', aws_key, aws_secret, opts)
|
|
289
|
+
|
|
290
|
+
### રેડિસ કેશીંગ નથી જોઈતું?
|
|
291
|
+
અક્ષમ કરવા માટે: જ્યારે તમે તમારું કનેક્શન સ્થાપિત કરો ત્યારે તમારા `opts.redisConfig` ઑબ્જેક્ટમાં `enabled: false` false` પાસ કરો.
|
|
292
|
+
|
|
293
|
+
નીચે ચર્ચા કર્યા મુજબ, કેશીંગને અક્ષમ કરવાથી કામગીરી પર પ્રતિકૂળ અસર પડશે અને વધુ વિનંતીઓ થશે
|
|
294
|
+
સ્ટોરેજ માટે જે તમારે ખરેખર જરૂરી છે.
|
|
295
|
+
|
|
296
|
+
### કેશીંગ માર્ગદર્શન
|
|
297
|
+
**એનક્રિપ્ટેડ સ્ટોરેજ**: એન્ક્રિપ્ટેડ સ્ટોરેજ વાંચવું/લેખવું સામાન્ય કરતાં થોડું ધીમું છે,
|
|
298
|
+
પરંતુ ડિરેક્ટરીઓની આસપાસ નેવિગેટ કરવું (જે કેટલીક વસ્તુઓ કરે છે) એકદમ ખર્ચાળ છે. રેડિસ કેશનો ઉપયોગ કરીને
|
|
299
|
+
તમને નોંધપાત્ર કામગીરી બૂસ્ટ આપશે.
|
|
300
|
+
|
|
301
|
+
ડિફૉલ્ટ કેશ સલામત છે, પરંતુ જો તમારી પાસે ઘણી બધી લખવા/દૂર કરવાની કામગીરી હોય તો તે સારું પ્રદર્શન કરતું નથી.
|
|
302
|
+
કોઈપણ લખવા અથવા દૂર કરવાની ક્રિયા સમગ્ર કેશને અમાન્ય બનાવે છે, ખાતરી કરો કે પછીના વાંચન જોશે
|
|
303
|
+
નવીનતમ ફેરફારો.
|
|
304
|
+
|
|
305
|
+
### CLI ટૂલ્સ
|
|
306
|
+
જો તમે CLI ટૂલનો ઉપયોગ કરી રહ્યાં છો જેમ કે [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
|
|
307
|
+
તમે ચોક્કસપણે redis કેશને સક્ષમ કરવા માંગો છો, કારણ કે તે `mo` આદેશની વિનંતીઓ દરમિયાન ચાલે છે.
|
|
308
|
+
|
|
309
|
+
## મિરરિંગ
|
|
310
|
+
|
|
311
|
+
// Copy a local filesystem mobiletto to S3
|
|
312
|
+
s3.mirror(local)
|
|
313
|
+
|
|
314
|
+
// Mirror a local subdirectory from one mobiletto to an S3 mobiletto, with it's own subdirectory
|
|
315
|
+
local.mirror(s3, 'some/local-folder', 'some/s3-folder')
|
|
316
|
+
|
|
317
|
+
`mirror` આદેશ એક મોબાઈલથી બીજા મોબાઈલ પર બધી ફાઈલોની એક વખતની નકલ કરે છે.
|
|
318
|
+
તે સમય સાથે અરીસાને જાળવવા માટે કોઈ પ્રક્રિયા ચલાવતું નથી. ફરીથી `mirror` આદેશ ચલાવો
|
|
319
|
+
કોઈપણ ખૂટતી ફાઇલોને સિંક્રનાઇઝ કરવા માટે.
|
|
320
|
+
|
|
321
|
+
`mirror` માંથી રીટર્ન વેલ્યુ એ એક સરળ ઑબ્જેક્ટ છે જેમાં કેટલી ફાઇલો સફળતાપૂર્વક હતી તેના કાઉન્ટર્સ છે
|
|
322
|
+
પ્રતિબિંબિત અને કેટલી ફાઇલોમાં ભૂલો હતી:
|
|
323
|
+
|
|
324
|
+
{
|
|
325
|
+
success: count-of-files-mirrored,
|
|
326
|
+
errors: count-of-files-with-errors
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
ચેતવણી: મોટા ડેટા સેટ્સને પ્રતિબિંબિત કરવું ખૂબ જ સમય માંગી લેતું અને બેન્ડવિડ્થ-સઘન હોઈ શકે છે
|
|
330
|
+
|
|
331
|
+
`mirror` કૉલ સિમેન્ટિક્સ સાથે તે કોણ છે તે સમજવામાં કેટલીકવાર મૂંઝવણમાં મૂકે છે
|
|
332
|
+
વાચક અને લેખક કોણ છે. તેને અસાઇનમેન્ટ સ્ટેટમેન્ટની જેમ કલ્પના કરો: "ડાબા હાથનો મોબાઈલ"
|
|
333
|
+
તે વસ્તુને સોંપવામાં આવી રહી છે (મિરર કરેલ ડેટા લખાયેલો), અને "જમણે હાથે મોબાઇલટો" (આ
|
|
334
|
+
`mirror` પદ્ધતિની દલીલ) એ સોંપેલ મૂલ્ય છે (મિરર કરેલ ડેટા વાંચવામાં આવે છે).
|
|
335
|
+
|
|
336
|
+
## પારદર્શક એન્ક્રિપ્શન
|
|
337
|
+
પારદર્શક ક્લાયંટ-સાઇડ એન્ક્રિપ્શન સક્ષમ કરો:
|
|
338
|
+
|
|
339
|
+
// Pass encryption parameters
|
|
340
|
+
const encryption = {
|
|
341
|
+
// key is required, must be >= 16 chars
|
|
342
|
+
key: randomstring.generate(128),
|
|
343
|
+
|
|
344
|
+
// optional, the default is to derive IV from key
|
|
345
|
+
// when set, IV must be >= 16 chars
|
|
346
|
+
iv: randomstring.generate(128),
|
|
347
|
+
|
|
348
|
+
// optional, the default is aes-256-cbc
|
|
349
|
+
algo: 'aes-256-cbc'
|
|
350
|
+
}
|
|
351
|
+
const api = await mobiletto(driverName, key, secret, opts, encryption)
|
|
352
|
+
|
|
353
|
+
// Subsequent write operations will encrypt data (client side) when writing
|
|
354
|
+
// Subsequent read operations will decrypt data (client side) when reading
|
|
355
|
+
|
|
356
|
+
શું થઈ રહ્યું છે? એક અલગ "ડિરેક્ટરી એન્ટ્રી" (ડાયરન્ટ) ડિરેક્ટરી (એનક્રિપ્ટેડ) તેમાં કઈ ફાઈલો છે તે ટ્રેક કરે છે
|
|
357
|
+
ડિરેક્ટરી (ઉર્ફે ડાયરન્ટ ડિરેક્ટરી).
|
|
358
|
+
* `list` આદેશ ડિરેક્ટરી એન્ટ્રી ફાઇલોને વાંચે છે, સૂચિબદ્ધ દરેક પાથને ડિક્રિપ્ટ કરે છે; પછી દરેક ફાઇલ માટે મેટાડેટા પરત કરે છે
|
|
359
|
+
* `list` આદેશો વધુ બિનકાર્યક્ષમ છે, ખાસ કરીને મોટી સંખ્યામાં ફાઇલો ધરાવતી ડિરેક્ટરીઓ માટે
|
|
360
|
+
* `write` આદેશ દરેક પેરેન્ટની ડાયરન્ટ ડાયરેક્ટરીમાં ડાયરન્ટ ફાઇલો લખે છે, પુનરાવર્તિત રીતે; પછી ફાઇલ લખે છે
|
|
361
|
+
ડાયરેક્ટરી વંશવેલોમાં N = ઊંડાઈ સાથે * `write` આદેશો O(N) લખે છે.
|
|
362
|
+
* `remove` કમાન્ડ અનુરૂપ ડાયરન્ટ ફાઇલને દૂર કરે છે, અને જો ખાલી હોય તો તેના પેરેન્ટને પુનરાવર્તિત રીતે દૂર કરે છે; પછી ફાઈલ દૂર કરે છે
|
|
363
|
+
* બિન-પુનરાવર્તિત `remove` આદેશો O(N) રીડ અને સંભવિત રૂપે ઘણા બધા ડિલીટ કરશે, જેમાં ડિરેક્ટરી વંશવેલોમાં N = ઊંડાઈ હશે.
|
|
364
|
+
* મોટી અને ડીપ ફાઇલસિસ્ટમ પર પુનરાવર્તિત `remove` કરો' આદેશો ખર્ચાળ હોઇ શકે છે
|
|
365
|
+
|
|
366
|
+
નોંધ કરો કે ક્લાયંટ-સાઇડ એન્ક્રિપ્શન સક્ષમ હોવા છતાં, તમારા એન્ક્રિપ્ટેડ સર્વર-સાઇડમાં સંપૂર્ણ દૃશ્યતા સાથે વિરોધી
|
|
367
|
+
સ્ટોરેજ, કી વગર પણ, હજુ પણ ડિરેક્ટરીઓની કુલ સંખ્યા અને દરેકમાં કેટલી ફાઈલો છે અને સાથે જોઈ શકે છે
|
|
368
|
+
કેટલાક પ્રયત્નો, ડિરેક્ટરી પદાનુક્રમની કેટલીક અથવા બધી એકંદર રચના શોધો.
|
|
369
|
+
*નોંધ: સારી સુરક્ષા માટે પ્રમાણમાં સપાટ માળખું વાપરો.*
|
|
370
|
+
પ્રતિસ્પર્ધી ડિરેક્ટરીઓ/ફાઈલોના નામ જાણશે નહીં સિવાય કે તેઓ તમારા એન્ક્રિપ્શનને પણ જાણતા હોય
|
|
371
|
+
કી અથવા અન્યથા સફળતાપૂર્વક એન્ક્રિપ્શન ક્રેક કર્યું હતું. બધા બેટ્સ પછી બંધ છે!
|
|
372
|
+
|
|
373
|
+
### પ્રદર્શન અને કેશીંગ
|
|
374
|
+
એન્ક્રિપ્ટેડ સ્ટોરેજ પરની કામગીરી ધીમી હોઈ શકે છે. પુનરાવર્તિત સૂચિઓ અને દૂર કરવાનું ખૂબ ધીમું હોઈ શકે છે.
|
|
375
|
+
redis દ્વારા કેશિંગ જબરદસ્ત રીતે મદદ કરે છે, પરંતુ નોંધ કરો કે કેશ કોઈપણ લખાણ અથવા દૂર કરવા પર ફ્લશ થાય છે.
|
|
376
|
+
|
|
377
|
+
## કી પરિભ્રમણ
|
|
378
|
+
તમારી નવી કી વડે મોબાઈલટો બનાવો, પછી તેમાં જૂના ડેટાને મિરર કરો:
|
|
379
|
+
|
|
380
|
+
const storage = require('mobiletto')
|
|
381
|
+
|
|
382
|
+
const oldEncryption = { key: .... }
|
|
383
|
+
const oldStorage = await storage.connect('s3', aws_key, aws_secret, {bucket: 'bk', region: 'us-east-1'}, oldEncryption)
|
|
384
|
+
|
|
385
|
+
const newEncryption = { key: .... }
|
|
386
|
+
const newStorage = await storage.connect('s3', aws_key, aws_secret, {bucket: 'zz', region: 'us-east-1'}, newEncryption)
|
|
387
|
+
|
|
388
|
+
newStorage.mirror(oldStorage) // if oldStorage is very large, this may take a looooooong time...
|
|
389
|
+
|
|
390
|
+
## ડ્રાઈવર ઈન્ટરફેસ
|
|
391
|
+
ડ્રાઇવર એ કોઈપણ JS ફાઇલ છે જે આ હસ્તાક્ષર સાથે 'storageClient' ફંક્શનની નિકાસ કરે છે:
|
|
392
|
+
|
|
393
|
+
function storageClient (key, secret, opts)
|
|
394
|
+
|
|
395
|
+
* `key` : એક સ્ટ્રિંગ, તમારી API કી ( `local` ડ્રાઇવર માટે આ બેઝ ડિરેક્ટરી છે)
|
|
396
|
+
* `secret` : એક શબ્દમાળા, તમારું API રહસ્ય ( `local` ડ્રાઇવર માટે અવગણી શકાય છે)
|
|
397
|
+
* `opts` : એક ઑબ્જેક્ટ, ગુણધર્મો પ્રતિ-ડ્રાઇવર છે:
|
|
398
|
+
* `local` માટે, `fileMode` અને `dirMode` ગુણધર્મો નક્કી કરે છે કે નવી બનાવવાની ફાઇલો અને ડિરેક્ટરીઓ કેવી રીતે બનાવવામાં આવે છે
|
|
399
|
+
* `s3` માટે, `bucket` ગુણધર્મ જરૂરી છે. વૈકલ્પિક ગુણધર્મો છે:
|
|
400
|
+
* `region`: the S3 region, default is us-east-1
|
|
401
|
+
* `prefix`: a prefix to prepend to all S3 paths, default is the empty string
|
|
402
|
+
* `delimiter`: the directory delimiter, default is '/'
|
|
403
|
+
|
|
404
|
+
ઑબ્જેક્ટ કે જે સ્ટોરેજ ક્લાયંટ ફંક્શન આપે છે તે આ કાર્યોને વ્યાખ્યાયિત કરે છે:
|
|
405
|
+
|
|
406
|
+
// Test the driver before using, ensure proper configuration
|
|
407
|
+
async testConfig ()
|
|
408
|
+
|
|
409
|
+
// List files in path (or from base-directory)
|
|
410
|
+
// If recursive is true, list recursively
|
|
411
|
+
// If visitor is defined, it will be an async function. await the visitor function on each file found
|
|
412
|
+
// Otherwise, perform the listing and return an array of objects
|
|
413
|
+
async list (path, recursive = false, visitor = null) // path may be omitted
|
|
414
|
+
|
|
415
|
+
// Read metadata for a path
|
|
416
|
+
async metadata (path)
|
|
417
|
+
|
|
418
|
+
// Read a file
|
|
419
|
+
// callback receives a chunk of data. endCallback is called at end-of-stream
|
|
420
|
+
async read (path, callback, endCallback = null)
|
|
421
|
+
|
|
422
|
+
// Write a file
|
|
423
|
+
// driver must be able to handle a generator or a stream
|
|
424
|
+
async write (path, generatorOrReadableStream)
|
|
425
|
+
|
|
426
|
+
// Remove a file, or recursively delete a directory
|
|
427
|
+
// returns a string of a single path removed, or an array of multiple paths removed
|
|
428
|
+
async remove (path, recursive = false, quiet = false)
|
|
429
|
+
|
|
430
|
+
## લોગીંગ
|
|
431
|
+
Mobiletto [winston](https://www.npmjs.com/package/winston) લૉગિંગ લાઇબ્રેરીનો ઉપયોગ કરે છે.
|
|
432
|
+
|
|
433
|
+
લૉગ્સમાં **ફાઇલ પાથ અને ભૂલ સંદેશાઓ હશે**, પરંતુ તેમાં **ક્યારેય** કી, રહસ્યો,
|
|
434
|
+
અથવા કોઈપણ અન્ય કનેક્શન રૂપરેખાંકન માહિતી.
|
|
435
|
+
|
|
436
|
+
### લોગ લેવલ
|
|
437
|
+
લોગ લેવલ સેટ કરવા માટે `MOBILETTO_LOG_LEVEL` પર્યાવરણ ચલનો ઉપયોગ કરો, એકનો ઉપયોગ કરીને
|
|
438
|
+
[https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels) માં વ્યાખ્યાયિત `npm` સ્તરોમાંથી
|
|
439
|
+
|
|
440
|
+
ડિફૉલ્ટ સ્તર `error` છે. સૌથી વર્બોઝ લેવલ `silly` છે, જો કે હાલમાં મોબાઇલટો
|
|
441
|
+
`debug` નીચેના સ્તરો પર લોગ થતું નથી
|
|
442
|
+
|
|
443
|
+
MOBILETTO_LOG_LEVEL=silly # maximum logs!
|
|
444
|
+
|
|
445
|
+
### લોગ ફાઈલ
|
|
446
|
+
મૂળભૂત રીતે, લોગર કન્સોલ પર લખે છે. ફાઇલમાં લોગ મોકલવા માટે, `MOBILETTO_LOG_FILE` સેટ કરો
|
|
447
|
+
પર્યાવરણ ચલ. ફાઇલમાં લોગીંગ કરતી વખતે, લોગ્સ હવે કન્સોલ પર લખવામાં આવશે નહીં.
|
|
448
|
+
|
|
449
|
+
MOBILETTO_LOG_FILE=/var/my_mobiletto_log
|
|
450
|
+
|
|
451
|
+
લોગીંગ બંધ કરવા માટે:
|
|
452
|
+
|
|
453
|
+
MOBILETTO_LOG_FILE=/dev/null
|
|
454
|
+
|
|
455
|
+
</pre>
|