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/ko/README.md
DELETED
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
모빌레토
|
|
2
|
-
==========
|
|
3
|
-
|
|
4
|
-
Mobiletto는 선택적 투명 클라이언트 측 암호화가 있는 JavaScript 스토리지 추상화 계층입니다.
|
|
5
|
-
|
|
6
|
-
# 내용물
|
|
7
|
-
* [왜 모빌레또인가?](#왜 모빌레또인가?)
|
|
8
|
-
* [빠른 시작](#빠른 시작)
|
|
9
|
-
* [모빌레토 CLI](#mobiletto-cli)
|
|
10
|
-
* [출처](#출처)
|
|
11
|
-
* [설치](#설치)
|
|
12
|
-
* [지원 및 펀딩](#지원 및 펀딩)
|
|
13
|
-
* [기본사용법](#기본사용법)
|
|
14
|
-
* [메타데이터](#메타데이터)
|
|
15
|
-
* [대체 가져오기 스타일](#대체 가져오기 스타일)
|
|
16
|
-
* [캐싱](#캐싱)
|
|
17
|
-
* [미러링](#미러링)
|
|
18
|
-
* [투명암호화](#투명암호화)
|
|
19
|
-
* [키 회전](#키 회전)
|
|
20
|
-
* [드라이버 인터페이스](#드라이버 인터페이스)
|
|
21
|
-
* [로깅](#로깅)
|
|
22
|
-
|
|
23
|
-
# 다른 언어로 읽어보세요
|
|
24
|
-
이 README.md 문서는 [hokeylization](https://github.com/cobbzilla/hokeylization)을 통해 다음으로 번역되었습니다.
|
|
25
|
-
**[Google 번역에서 지원하는 모든 언어](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
|
-
[🇰🇪 스와힐리어](../sw/README.md)
|
|
46
|
-
[🇵🇭 타갈로그어](../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에서 pull 요청](https://github.com/cobbzilla/mobiletto/pulls)을 보내주세요.
|
|
59
|
-
또는 그렇게 하는 것이 편하지 않다면 [문제 열기](https://github.com/cobbzilla/mobiletto/issues)
|
|
60
|
-
|
|
61
|
-
번역에 대한 새 GitHub 문제를 만들 때 다음을 수행하십시오.
|
|
62
|
-
* 페이지 URL 포함(브라우저 주소 표시줄에서 복사/붙여넣기)
|
|
63
|
-
* 잘못된 정확한 텍스트 포함(브라우저에서 복사/붙여넣기)
|
|
64
|
-
* 무엇이 잘못되었는지 설명해주세요 -- 번역이 잘못되었습니까? 형식이 어떻게 든 깨졌습니까?
|
|
65
|
-
* 더 나은 번역을 제안하거나 텍스트 형식을 올바르게 지정하는 방법을 알려주세요.
|
|
66
|
-
* **고맙습니다!**
|
|
67
|
-
|
|
68
|
-
## 왜 모빌레토인가?
|
|
69
|
-
|
|
70
|
-
### 공급업체 종속은 이제 안녕!
|
|
71
|
-
다양한 클라우드 스토리지 제공업체에는 호환되지 않는 API가 있습니다. "S3 호환성"을 추구하는 분들도
|
|
72
|
-
특이한 행동을 한다.
|
|
73
|
-
|
|
74
|
-
앱에 대한 특정 저장소 공급업체를 선택할 때 해당 API에 직접 코딩하면 앱이
|
|
75
|
-
이제 해당 서비스에 종속됩니다. 시간이 흐르고 코드가 누적됨에 따라 벤더 변경은
|
|
76
|
-
점점 버틸 수 없는. 벤더 종속의 재미있는 세계에 오신 것을 환영합니다!
|
|
77
|
-
|
|
78
|
-
Mobiletto는 이 문제를 해결하기 위해 설계되었습니다. 모바일토토의 API에 앱을 코딩하면 쉽게
|
|
79
|
-
저장소 공급자를 변경하고 앱의 저장소 계층이 동일하게 작동한다는 것을 알고 있습니다.
|
|
80
|
-
|
|
81
|
-
### 광범위한 테스트
|
|
82
|
-
모든 드라이버는 각 드라이버에 대해 60개 이상의 테스트를 통해 동일한 동작을 테스트합니다.
|
|
83
|
-
다음의 모든 조합으로 모든 드라이버를 테스트합니다.
|
|
84
|
-
* 암호화: 활성화 및 비활성화
|
|
85
|
-
* Redis 캐시: 활성화 및 비활성화
|
|
86
|
-
|
|
87
|
-
이 접근 방식은 사용하는 드라이버에 관계없이 mobiletto가 동일하게 작동한다는 마음의 평화를 제공합니다.
|
|
88
|
-
캐싱 및/또는 암호화를 활성화하는지 여부에 관계없이.
|
|
89
|
-
|
|
90
|
-
### 드라이버 지원
|
|
91
|
-
현재 Mobiletto 스토리지 드라이버:
|
|
92
|
-
* `s3` : 아마존 S3
|
|
93
|
-
* `b2` : 백블레이즈 B2
|
|
94
|
-
* `local` : 로컬 파일 시스템
|
|
95
|
-
|
|
96
|
-
*더 많은 클라우드 스토리지 제공업체를 지원하기 위한 기여를 환영합니다!*
|
|
97
|
-
|
|
98
|
-
## 모바일토클리
|
|
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
|
-
* [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` 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">redis</a> 캐시에서 가장 잘 작동합니다.
|
|
295
|
-
|
|
296
|
-
Mobiletto는 127.0.0.1:6379에서 redis 인스턴스에 연결을 시도합니다.
|
|
297
|
-
|
|
298
|
-
다음 중 하나를 재정의할 수 있습니다.
|
|
299
|
-
* `MOBILETTO_REDIS_HOST` env var, mobilet 설정하여 localhost 대신 여기에 연결
|
|
300
|
-
* `MOBILETTO_REDIS_PORT` 환경 변수를 설정합니다. 이 포트가 사용됩니다.
|
|
301
|
-
|
|
302
|
-
Mobiletto는 모든 redis 키를 접두사 `_mobiletto__` 로 저장합니다. 당신은 이것을 변경할 수 있습니다
|
|
303
|
-
`MOBILETTO_REDIS_PREFIX` 환경 변수를 설정하여
|
|
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 캐싱을 원하지 않습니까?
|
|
317
|
-
비활성화하려면: 연결을 설정할 때 `opts.redisConfig` 개체에 `enabled: false` false`를 전달합니다.
|
|
318
|
-
|
|
319
|
-
아래에서 설명하는 것처럼 캐싱을 비활성화하면 성능에 부정적인 영향을 미치고 더 많은 요청이 발생합니다.
|
|
320
|
-
정말 필요한 스토리지에.
|
|
321
|
-
|
|
322
|
-
### 캐싱 안내
|
|
323
|
-
**암호화된 저장소**: 암호화된 저장소 읽기/쓰기가 평소보다 약간 느립니다.
|
|
324
|
-
그러나 디렉토리를 탐색하는 것(일부 작업이 수행함)은 상당히 비쌉니다. 레디스 캐시 사용
|
|
325
|
-
상당한 성능 향상을 제공합니다.
|
|
326
|
-
|
|
327
|
-
기본 캐시는 안전하지만 쓰기/제거 작업이 많은 경우에는 제대로 작동하지 않습니다.
|
|
328
|
-
모든 쓰기 또는 제거 작업은 전체 캐시를 무효화하여 후속 읽기에서
|
|
329
|
-
최신 변경 사항.
|
|
330
|
-
|
|
331
|
-
### CLI 도구
|
|
332
|
-
[mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)와 같은 CLI 도구를 사용하는 경우,
|
|
333
|
-
`mo` 명령을 호출하는 동안 지속되므로 redis 캐시를 활성화해야 합니다.
|
|
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` 명령은 한 mobiletto에서 다른 mobiletto로 모든 파일의 일회성 복사를 수행합니다.
|
|
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
|
-
독자와 작가는 누구인가. "left-hand mobiletto"라는 할당문처럼 상상해보십시오.
|
|
359
|
-
(미러링된 데이터 쓰기)에 할당된 것, 그리고 "오른쪽 모빌레토"(
|
|
360
|
-
`mirror` 메서드에 대한 인수)는 할당되는 값입니다(미러링된 데이터를 읽음).
|
|
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
|
-
디렉토리(일명 디렉토리 디렉토리).
|
|
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
|
-
storageClient 함수가 반환하는 객체는 다음 함수를 정의해야 합니다.
|
|
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` 입니다. 가장 장황한 수준은 `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>
|