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.
Files changed (117) hide show
  1. package/README.md +56 -4
  2. package/docs/README.md +113 -0
  3. package/docs/af/README.md +455 -0
  4. package/docs/am/README.md +455 -0
  5. package/docs/ar/README.md +455 -0
  6. package/docs/az/README.md +455 -0
  7. package/docs/be/README.md +455 -0
  8. package/docs/bg/README.md +455 -0
  9. package/docs/bn/README.md +455 -0
  10. package/docs/bs/README.md +455 -0
  11. package/docs/ca/README.md +455 -0
  12. package/docs/ceb/README.md +455 -0
  13. package/docs/co/README.md +455 -0
  14. package/docs/cs/README.md +455 -0
  15. package/docs/cy/README.md +455 -0
  16. package/docs/da/README.md +455 -0
  17. package/docs/de/README.md +455 -0
  18. package/docs/el/README.md +455 -0
  19. package/docs/eo/README.md +455 -0
  20. package/docs/es/README.md +455 -0
  21. package/docs/et/README.md +455 -0
  22. package/docs/eu/README.md +455 -0
  23. package/docs/fa/README.md +455 -0
  24. package/docs/fi/README.md +455 -0
  25. package/docs/fr/README.md +455 -0
  26. package/docs/fy/README.md +455 -0
  27. package/docs/ga/README.md +455 -0
  28. package/docs/gd/README.md +455 -0
  29. package/docs/gl/README.md +455 -0
  30. package/docs/gu/README.md +455 -0
  31. package/docs/ha/README.md +455 -0
  32. package/docs/haw/README.md +455 -0
  33. package/docs/he/README.md +455 -0
  34. package/docs/hi/README.md +455 -0
  35. package/docs/hmn/README.md +455 -0
  36. package/docs/hr/README.md +455 -0
  37. package/docs/ht/README.md +455 -0
  38. package/docs/hu/README.md +455 -0
  39. package/docs/hy/README.md +455 -0
  40. package/docs/id/README.md +455 -0
  41. package/docs/ig/README.md +455 -0
  42. package/docs/is/README.md +455 -0
  43. package/docs/it/README.md +455 -0
  44. package/docs/iw/README.md +455 -0
  45. package/docs/ja/README.md +455 -0
  46. package/docs/jv/README.md +455 -0
  47. package/docs/ka/README.md +455 -0
  48. package/docs/kk/README.md +455 -0
  49. package/docs/km/README.md +455 -0
  50. package/docs/kn/README.md +455 -0
  51. package/docs/ko/README.md +455 -0
  52. package/docs/ku/README.md +455 -0
  53. package/docs/ky/README.md +455 -0
  54. package/docs/la/README.md +455 -0
  55. package/docs/lb/README.md +455 -0
  56. package/docs/lo/README.md +455 -0
  57. package/docs/lt/README.md +455 -0
  58. package/docs/lv/README.md +455 -0
  59. package/docs/mg/README.md +455 -0
  60. package/docs/mi/README.md +455 -0
  61. package/docs/mk/README.md +455 -0
  62. package/docs/ml/README.md +455 -0
  63. package/docs/mn/README.md +455 -0
  64. package/docs/mr/README.md +455 -0
  65. package/docs/ms/README.md +455 -0
  66. package/docs/mt/README.md +455 -0
  67. package/docs/my/README.md +455 -0
  68. package/docs/ne/README.md +455 -0
  69. package/docs/nl/README.md +455 -0
  70. package/docs/no/README.md +455 -0
  71. package/docs/ny/README.md +455 -0
  72. package/docs/or/README.md +455 -0
  73. package/docs/pa/README.md +455 -0
  74. package/docs/pl/README.md +455 -0
  75. package/docs/ps/README.md +455 -0
  76. package/docs/pt/README.md +455 -0
  77. package/docs/ro/README.md +455 -0
  78. package/docs/ru/README.md +455 -0
  79. package/docs/rw/README.md +455 -0
  80. package/docs/sd/README.md +455 -0
  81. package/docs/si/README.md +455 -0
  82. package/docs/sk/README.md +455 -0
  83. package/docs/sl/README.md +455 -0
  84. package/docs/sm/README.md +455 -0
  85. package/docs/sn/README.md +455 -0
  86. package/docs/so/README.md +455 -0
  87. package/docs/sq/README.md +455 -0
  88. package/docs/sr/README.md +455 -0
  89. package/docs/st/README.md +455 -0
  90. package/docs/su/README.md +455 -0
  91. package/docs/sv/README.md +455 -0
  92. package/docs/sw/README.md +455 -0
  93. package/docs/ta/README.md +455 -0
  94. package/docs/te/README.md +455 -0
  95. package/docs/tg/README.md +455 -0
  96. package/docs/th/README.md +455 -0
  97. package/docs/tk/README.md +455 -0
  98. package/docs/tl/README.md +455 -0
  99. package/docs/tr/README.md +455 -0
  100. package/docs/tt/README.md +455 -0
  101. package/docs/ug/README.md +455 -0
  102. package/docs/uk/README.md +455 -0
  103. package/docs/ur/README.md +455 -0
  104. package/docs/uz/README.md +455 -0
  105. package/docs/vi/README.md +455 -0
  106. package/docs/xh/README.md +455 -0
  107. package/docs/yi/README.md +455 -0
  108. package/docs/yo/README.md +455 -0
  109. package/docs/zh/README.md +455 -0
  110. package/docs/zu/README.md +455 -0
  111. package/drivers/b2/index.js +24 -6
  112. package/hokey.json +16 -0
  113. package/index.js +33 -17
  114. package/package.json +3 -2
  115. package/test/api.spec.js +319 -306
  116. package/util/logger.js +1 -1
  117. package/util/redis.js +1 -1
@@ -0,0 +1,455 @@
1
+ モビレット
2
+ =========
3
+
4
+ Mobiletto は、オプションの透過的なクライアント側暗号化を備えた JavaScript ストレージ抽象化レイヤーです。
5
+
6
+ # コンテンツ
7
+ * [Why Mobiletto?](#Why-Mobiletto?)
8
+ * [クイックスタート](#クイックスタート)
9
+ * [Mobiletto CLI](#mobiletto-cli)
10
+ * [ソース](#ソース)
11
+ * [基本的な使い方](#基本的な使い方)
12
+ * [メタデータ](#メタデータ)
13
+ * [代替インポート スタイル](#代替インポート スタイル)
14
+ * [キャッシング](#キャッシング)
15
+ * [ミラーリング](#ミラーリング)
16
+ * [透過的暗号化](#Transparent-encryption)
17
+ * [キーローテーション](#Key-rotation)
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
+ * Redis キャッシュ: 有効と無効の両方
84
+
85
+ このアプローチにより、使用するドライバーに関係なく、mobiletto が同じように動作するという安心感が得られます。
86
+ キャッシュや暗号化を有効にするかどうかに関係なく。
87
+
88
+ ### ドライバーのサポート
89
+ 現在の Mobiletto ストレージ ドライバー:
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
+ * [GitHub 上のモビレット](https://github.com/cobbzilla/mobiletto)
103
+ * [npm上のmobiletto](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` 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
+ Mobiletto は<a href="https://redis.io">redis</a>キャッシュで最適に動作します。
269
+
270
+ Mobiletto は 127.0.0.1:6379 で redis インスタンスへの接続を試みます
271
+
272
+ 次のいずれかをオーバーライドできます。
273
+ * `MOBILETTO_REDIS_HOST`を設定し、mobiletto は localhost の代わりにここに接続します
274
+ * `MOBILETTO_REDIS_PORT`を設定すると、このポートが使用されます
275
+
276
+ Mobiletto はすべての redis キーをプレフィックス`_mobiletto__`で保存します。これを変更できます
277
+ `MOBILETTO_REDIS_PREFIX`を設定することにより。
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
+ ### redis キャッシングが不要ですか?
291
+ 無効にするには: 接続を確立するときに、 `opts.redisConfig`オブジェクトに`enabled: false` false」を渡します。
292
+
293
+ 以下で説明するように、キャッシュを無効にすると、パフォーマンスに悪影響を及ぼし、より多くのリクエストが発生します。
294
+ 本当に必要なストレージに。
295
+
296
+ ### キャッシングのガイダンス
297
+ **暗号化されたストレージ**: 暗号化されたストレージの読み取り/書き込みは、通常よりわずかに遅くなります。
298
+ しかし、ディレクトリをナビゲートする (いくつかの場合) にはかなりのコストがかかります。 redis キャッシュの使用
299
+ パフォーマンスを大幅に向上させます。
300
+
301
+ デフォルトのキャッシュは安全ですが、書き込み/削除操作が多い場合はうまく機能しません。
302
+ 書き込みまたは削除操作を行うと、キャッシュ全体が無効になり、後続の読み取りで確実に
303
+ 最新の変更。
304
+
305
+ ### CLI ツール
306
+ [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli) などの 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`コマンドは、1 つの mobiletto から別の mobiletto へのすべてのファイルの 1 回限りのコピーを実行します。
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
+ 何が起こっていますか?別の「ディレクトリ エントリ」(dirent) ディレクトリ (暗号化された) は、その中にあるファイルを追跡します。
357
+ ディレクトリ (dirent ディレクトリとも呼ばれます)。
358
+ * `list`コマンドは、ディレクトリ エントリ ファイルを読み取り、リストされた各パスを復号化します。次に、各ファイルのメタデータを返します
359
+ * `list`コマンドは、特に多数のファイルを含むディレクトリの場合、より非効率的です
360
+ * `write`コマンドは、各親の dirent ディレクトリに dirent ファイルを再帰的に書き込みます。次に、ファイルを書き込みます
361
+ * `write`コマンドは O(N) 回の書き込みを発生させます。N = ディレクトリ階層の深さ
362
+ * `remove`コマンドは、対応する dirent ファイルを削除し、空の場合はその親を再帰的に削除します。次に、ファイルを削除します
363
+ * 非再帰的な`remove`コマンドは、O(N) 回の読み取りと潜在的に同じ数の削除を発生させます (N = ディレクトリ階層の深さ)。
364
+ * 大規模で深いファイルシステムでの再帰的な`remove`コマンドはコストがかかる可能性があります
365
+
366
+ クライアント側の暗号化が有効になっている場合でも、敵対者は暗号化されたサーバー側を完全に可視化できることに注意してください
367
+ ストレージは、キーがなくても、ディレクトリの総数とそれぞれにあるファイルの数を確認できます。
368
+ 少し努力して、ディレクトリ階層の全体構造の一部またはすべてを発見してください。
369
+ *注: セキュリティを強化するために、比較的平らな構造を使用してください。*
370
+ 敵対者は、あなたの暗号化も知らない限り、ディレクトリ/ファイルの名前を知りません
371
+ キーまたは他の方法で暗号化のクラックに成功した可能性があります。その時、すべての賭けはオフです!
372
+
373
+ ### パフォーマンスとキャッシング
374
+ 暗号化されたストレージの操作は遅くなる可能性があります。再帰的なリストと削除は非常に遅くなる可能性があります。
375
+ redis によるキャッシュは非常に役立ちますが、キャッシュは書き込みまたは削除時にフラッシュされることに注意してください。
376
+
377
+ ## キーローテーション
378
+ 新しいキーで mobiletto を作成し、古いデータをそこにミラーリングします。
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
+ ドライバーは、次のシグネチャを使用して「storageClient」関数をエクスポートする任意の JS ファイルです。
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
+ storageClient 関数が返すオブジェクトは、次の関数を定義する必要があります。
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`ですが、現在 mobiletto
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>