mobiletto 1.2.1 → 2.0.0

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 (124) hide show
  1. package/lib/cjs/index.d.ts +2 -0
  2. package/lib/cjs/index.js +30 -0
  3. package/lib/cjs/package.json +16 -0
  4. package/lib/esm/index.d.ts +2 -0
  5. package/lib/esm/index.js +12 -0
  6. package/package.json +27 -13
  7. package/.babelrc +0 -5
  8. package/.eslintrc.js +0 -14
  9. package/docs/README.md +0 -113
  10. package/docs/af/README.md +0 -481
  11. package/docs/am/README.md +0 -481
  12. package/docs/ar/README.md +0 -481
  13. package/docs/az/README.md +0 -481
  14. package/docs/be/README.md +0 -481
  15. package/docs/bg/README.md +0 -481
  16. package/docs/bn/README.md +0 -481
  17. package/docs/bs/README.md +0 -481
  18. package/docs/ca/README.md +0 -481
  19. package/docs/ceb/README.md +0 -481
  20. package/docs/co/README.md +0 -481
  21. package/docs/cs/README.md +0 -481
  22. package/docs/cy/README.md +0 -481
  23. package/docs/da/README.md +0 -481
  24. package/docs/de/README.md +0 -481
  25. package/docs/el/README.md +0 -481
  26. package/docs/eo/README.md +0 -481
  27. package/docs/es/README.md +0 -481
  28. package/docs/et/README.md +0 -481
  29. package/docs/eu/README.md +0 -481
  30. package/docs/fa/README.md +0 -481
  31. package/docs/fi/README.md +0 -481
  32. package/docs/fr/README.md +0 -481
  33. package/docs/fy/README.md +0 -481
  34. package/docs/ga/README.md +0 -481
  35. package/docs/gd/README.md +0 -481
  36. package/docs/gl/README.md +0 -481
  37. package/docs/gu/README.md +0 -481
  38. package/docs/ha/README.md +0 -481
  39. package/docs/haw/README.md +0 -481
  40. package/docs/he/README.md +0 -481
  41. package/docs/hi/README.md +0 -481
  42. package/docs/hmn/README.md +0 -481
  43. package/docs/hr/README.md +0 -481
  44. package/docs/ht/README.md +0 -481
  45. package/docs/hu/README.md +0 -481
  46. package/docs/hy/README.md +0 -481
  47. package/docs/id/README.md +0 -481
  48. package/docs/ig/README.md +0 -481
  49. package/docs/is/README.md +0 -481
  50. package/docs/it/README.md +0 -481
  51. package/docs/iw/README.md +0 -481
  52. package/docs/ja/README.md +0 -481
  53. package/docs/jv/README.md +0 -481
  54. package/docs/ka/README.md +0 -481
  55. package/docs/kk/README.md +0 -481
  56. package/docs/km/README.md +0 -481
  57. package/docs/kn/README.md +0 -481
  58. package/docs/ko/README.md +0 -481
  59. package/docs/ku/README.md +0 -481
  60. package/docs/ky/README.md +0 -481
  61. package/docs/la/README.md +0 -481
  62. package/docs/lb/README.md +0 -481
  63. package/docs/lo/README.md +0 -481
  64. package/docs/lt/README.md +0 -481
  65. package/docs/lv/README.md +0 -481
  66. package/docs/mg/README.md +0 -481
  67. package/docs/mi/README.md +0 -481
  68. package/docs/mk/README.md +0 -481
  69. package/docs/ml/README.md +0 -481
  70. package/docs/mn/README.md +0 -481
  71. package/docs/mr/README.md +0 -481
  72. package/docs/ms/README.md +0 -481
  73. package/docs/mt/README.md +0 -481
  74. package/docs/my/README.md +0 -481
  75. package/docs/ne/README.md +0 -481
  76. package/docs/nl/README.md +0 -481
  77. package/docs/no/README.md +0 -481
  78. package/docs/ny/README.md +0 -481
  79. package/docs/or/README.md +0 -481
  80. package/docs/pa/README.md +0 -481
  81. package/docs/pl/README.md +0 -481
  82. package/docs/ps/README.md +0 -481
  83. package/docs/pt/README.md +0 -481
  84. package/docs/ro/README.md +0 -481
  85. package/docs/ru/README.md +0 -481
  86. package/docs/rw/README.md +0 -481
  87. package/docs/sd/README.md +0 -481
  88. package/docs/si/README.md +0 -481
  89. package/docs/sk/README.md +0 -481
  90. package/docs/sl/README.md +0 -481
  91. package/docs/sm/README.md +0 -481
  92. package/docs/sn/README.md +0 -481
  93. package/docs/so/README.md +0 -481
  94. package/docs/sq/README.md +0 -481
  95. package/docs/sr/README.md +0 -481
  96. package/docs/st/README.md +0 -481
  97. package/docs/su/README.md +0 -481
  98. package/docs/sv/README.md +0 -481
  99. package/docs/sw/README.md +0 -481
  100. package/docs/ta/README.md +0 -481
  101. package/docs/te/README.md +0 -481
  102. package/docs/tg/README.md +0 -481
  103. package/docs/th/README.md +0 -481
  104. package/docs/tk/README.md +0 -481
  105. package/docs/tl/README.md +0 -481
  106. package/docs/tr/README.md +0 -481
  107. package/docs/tt/README.md +0 -481
  108. package/docs/ug/README.md +0 -481
  109. package/docs/uk/README.md +0 -481
  110. package/docs/ur/README.md +0 -481
  111. package/docs/uz/README.md +0 -481
  112. package/docs/vi/README.md +0 -481
  113. package/docs/xh/README.md +0 -481
  114. package/docs/yi/README.md +0 -481
  115. package/docs/yo/README.md +0 -481
  116. package/docs/zh/README.md +0 -481
  117. package/docs/zu/README.md +0 -481
  118. package/drivers/b2/index.js +0 -451
  119. package/drivers/local/index.js +0 -315
  120. package/drivers/s3/index.js +0 -316
  121. package/hokey.json +0 -16
  122. package/index.js +0 -29
  123. package/test/api.spec.js +0 -512
  124. package/test/crypt.spec.js +0 -67
package/docs/lo/README.md DELETED
@@ -1,481 +0,0 @@
1
- ໂທລະສັບມືຖື
2
- =========
3
-
4
- Mobiletto ເປັນຊັ້ນ abstraction ການເກັບຮັກສາ JavaScript, ມີທາງເລືອກໃນການເຂົ້າລະຫັດດ້ານລູກຄ້າໂປ່ງໃສ.
5
-
6
- # ເນື້ອໃນ
7
- * [ເປັນຫຍັງ Mobiletto?](#Why-Mobiletto?)
8
- * [ເລີ່ມ​ຕົ້ນ​ດ່ວນ](#ເລີ່ມ​ຕົ້ນ​ດ່ວນ​)
9
- * [Mobiletto CLI](#mobiletto-cli)
10
- * [ແຫຼ່ງຂໍ້ມູນ](#ແຫຼ່ງຂໍ້ມູນ)
11
- * [ການ​ຕິດ​ຕັ້ງ​](# ການ​ຕິດ​ຕັ້ງ​)
12
- * [ການ​ສະ​ຫນັບ​ສະ​ຫນູນ​ແລະ​ການ​ສະ​ຫນອງ​ທຶນ​](#Support-and-Funding​)
13
- * [ການ​ນໍາ​ໃຊ້​ພື້ນ​ຖານ​](# ການ​ນໍາ​ໃຊ້​ພື້ນ​ຖານ​)
14
- * [Metadata](#Metadata)
15
- * [ຮູບແບບການນຳເຂົ້າສຳຮອງ](#ຮູບແບບການນຳເຂົ້າສຳຮອງ)
16
- * [Caching](#Caching)
17
- * [ການສະທ້ອນ](#ການສະທ້ອນ)
18
- * [ການເຂົ້າລະຫັດໂປ່ງໃສ](#Transparent-encryption)
19
- * [ການ​ຫມຸນ​ກະ​ແຈ](#ການ​ຫມຸນ​ກະ​ແຈ​)
20
- * [ການໂຕ້ຕອບຄົນຂັບ](#Driver-interface)
21
- * [ບັນທຶກ](#Logging)
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
- [🇧🇩 Bengali](../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
- [🇮🇹 Italian](../it/README.md)
39
- [🇯🇵 ພາສາຍີ່ປຸ່ນ](../ja/README.md)
40
- [🇰🇷ເກົາຫຼີ](../ko/README.md)
41
- [🇮🇳 Marathi](../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
- [🇵🇰 Urdu](../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
- ຜູ້ໃຫ້ບໍລິການເກັບຮັກສາຟັງຄລາວຕ່າງໆມີ APIs ທີ່ບໍ່ເຂົ້າກັນໄດ້. ເຖິງແມ່ນວ່າຜູ້ທີ່ພະຍາຍາມ "ເຂົ້າກັນໄດ້ S3"
72
- ມີພຶດຕິກໍາ idiosyncratic.
73
-
74
- ເມື່ອທ່ານເລືອກຜູ້ຂາຍບ່ອນເກັບຂໍ້ມູນສະເພາະສໍາລັບແອັບຯຂອງທ່ານ, ຖ້າທ່ານລະຫັດໂດຍກົງໃສ່ API ຂອງພວກເຂົາ, ແອັບຯຂອງທ່ານ
75
- ໃນປັດຈຸບັນແມ່ນຂຶ້ນກັບການບໍລິການນັ້ນ. ເມື່ອເວລາຜ່ານໄປແລະລະຫັດສະສົມ, ຜູ້ຂາຍປ່ຽນກາຍເປັນ
76
- untenable ຫຼາຍ​ຂຶ້ນ​. ຍິນດີຕ້ອນຮັບສູ່ໂລກທີ່ມ່ວນຊື່ນຂອງຜູ້ຂາຍລັອກອິນ!
77
-
78
- Mobiletto ໄດ້​ຖືກ​ອອກ​ແບບ​ເພື່ອ​ແກ້​ໄຂ​ບັນ​ຫາ​ນີ້​. ໂດຍການໃສ່ລະຫັດແອັບຯຂອງທ່ານໃສ່ API ຂອງ mobiletto, ທ່ານສາມາດໄດ້ຢ່າງງ່າຍດາຍ
79
- ປ່ຽນຜູ້ໃຫ້ບໍລິການບ່ອນເກັບຂໍ້ມູນ ແລະຮູ້ວ່າຊັ້ນເກັບຂໍ້ມູນຂອງແອັບຯຂອງເຈົ້າຈະມີລັກສະນະຄືກັນ.
80
-
81
- ### ການທົດສອບຢ່າງກວ້າງຂວາງ
82
- ຄົນຂັບທັງໝົດຖືກທົດສອບສຳລັບພຶດຕິກຳທີ່ຄືກັນດ້ວຍການທົດສອບ 60+ ສຳລັບຄົນຂັບແຕ່ລະຄົນ.
83
- ພວກ​ເຮົາ​ທົດ​ສອບ​ຄົນ​ຂັບ​ທັງ​ຫມົດ​ທີ່​ມີ​ການ​ປະ​ສົມ​ປະ​ສານ​ຂອງ​:
84
- * ການເຂົ້າລະຫັດ: ທັງເປີດ ແລະປິດໃຊ້ງານ
85
- * ແຄດ Redis: ທັງເປີດ ແລະປິດໃຊ້ງານ
86
-
87
- ວິທີການນີ້ເຮັດໃຫ້ພວກເຮົາສະຫງົບໃຈວ່າ mobiletto ຈະປະຕິບັດຕົວດຽວກັນບໍ່ວ່າທ່ານຈະໃຊ້ຄົນຂັບໃດກໍ່ຕາມ,
88
- ແລະບໍ່ຄໍານຶງເຖິງວ່າທ່ານຈະເປີດໃຊ້ caching ແລະ/ຫຼື encryption.
89
-
90
- ### ສະຫນັບສະຫນູນຄົນຂັບ
91
- ໄດເວີການເກັບຮັກສາ Mobiletto ໃນປັດຈຸບັນ:
92
- * `s3` : Amazon S3
93
- * `b2` : Backblaze B2
94
- * `local` ທ້ອງຖິ່ນ`: ລະບົບໄຟລ໌ທ້ອງຖິ່ນ
95
-
96
- *ການປະກອບສ່ວນເພື່ອສະໜັບສະໜູນຜູ້ໃຫ້ບໍລິການຈັດເກັບຂໍ້ມູນຄລາວຫຼາຍຂຶ້ນແມ່ນຍິນດີຕ້ອນຮັບຫຼາຍ!*
97
-
98
- ## mobiletto-cli
99
- Mobiletto ມີຈຸດປະສົງເພື່ອໃຊ້ເປັນຫ້ອງສະຫມຸດໂດຍລະຫັດ JavaScript ອື່ນໆ.
100
-
101
- ເພື່ອເຮັດວຽກກັບ mobiletto ຢູ່ແຖວຄໍາສັ່ງ, ໃຫ້ໃຊ້ [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli)
102
-
103
- ## ທີ່ມາ
104
- * [mobiletto ໃນ GitHub](https://github.com/cobbzilla/mobiletto)
105
- * [mobiletto ສຸດ npm](https://www.npmjs.com/package/mobiletto)
106
-
107
- ## ສະໜັບສະໜູນ ແລະ ສະໜອງທຶນ
108
- ຂ້ອຍພະຍາຍາມເປັນຜູ້ພັດທະນາຊອບແວ open source ມືອາຊີບ. ຂ້ອຍໄດ້ເຮັດວຽກຢູ່ໃນ
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` ຕອບ metadata ກ່ຽວກັບການປ້ອນລະບົບໄຟລ໌ດຽວ.
268
- ເຊັ່ນດຽວກັນ, ມູນຄ່າກັບຄືນຈາກຄໍາສັ່ງ `list` ແມ່ນ array ຂອງວັດຖຸ metadata.
269
-
270
- ວັດຖຸ metadata ເບິ່ງຄືວ່ານີ້:
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">redis</a> cache.
295
-
296
- Mobiletto ຈະພະຍາຍາມເຊື່ອມຕໍ່ກັບຕົວຢ່າງ redis ໃນ 127.0.0.1:6379
297
-
298
- ທ່ານສາມາດ override ທັງສອງອັນນີ້:
299
- * ຕັ້ງ `MOBILETTO_REDIS_HOST` env var, mobiletto ເຊື່ອມຕໍ່ທີ່ນີ້ແທນ localhost
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
- ເພື່ອປິດການໃຊ້ງານ: pass `enabled: false` ໃນວັດຖຸ `opts.redisConfig` ຂອງທ່ານເມື່ອທ່ານສ້າງການເຊື່ອມຕໍ່ຂອງທ່ານ.
318
-
319
- ດັ່ງທີ່ໄດ້ກ່າວໄວ້ຂ້າງລຸ່ມນີ້, ການປິດການໃຊ້ງານຖານຄວາມຈໍາຈະມີຜົນກະທົບທາງລົບຕໍ່ການປະຕິບັດແລະເຮັດໃຫ້ເກີດການຮ້ອງຂໍເພີ່ມເຕີມ
320
- ເພື່ອເກັບຮັກສາທີ່ເຈົ້າຕ້ອງການແທ້ໆ.
321
-
322
- ### ການແນະນຳການເກັບຂໍ້ມູນ
323
- ** ການ​ເກັບ​ຮັກ​ສາ​ເຂົ້າ​ລະ​ຫັດ **​: ການ​ອ່ານ / ການ​ຂຽນ​ການ​ເກັບ​ຮັກ​ສາ​ເຂົ້າ​ລະ​ຫັດ​ແມ່ນ​ພຽງ​ແຕ່​ຊ້າ​ກ​່​ວາ​ປົກ​ກະ​ຕິ​ເລັກ​ນ້ອຍ​,
324
- ແຕ່ການທ່ອງໄປຫາໄດເລກະທໍລີ (ທີ່ບາງສິ່ງທີ່ເຮັດ) ແມ່ນລາຄາແພງພໍສົມຄວນ. ການ​ນໍາ​ໃຊ້​ຖານ​ຄວາມ​ຈໍາ redis​
325
- ຈະໃຫ້ທ່ານມີການເພີ່ມປະສິດທິພາບທີ່ສໍາຄັນ.
326
-
327
- cache ເລີ່ມຕົ້ນແມ່ນປອດໄພ, ແຕ່ບໍ່ດີຖ້າທ່ານມີການດໍາເນີນງານການຂຽນ / ລົບຫຼາຍ.
328
- ການ​ດໍາ​ເນີນ​ງານ​ການ​ຂຽນ​ຫຼື​ລົບ​ໃດໆ invalidates cache ທັງ​ຫມົດ​, ການ​ຮັບ​ປະ​ກັນ​ການ​ອ່ານ​ຕໍ່​ໄປ​ຈະ​ເຫັນ​ໄດ້​
329
- ການປ່ຽນແປງຫຼ້າສຸດ.
330
-
331
- ### ເຄື່ອງມື CLI
332
- ຖ້າທ່ານກໍາລັງໃຊ້ເຄື່ອງມື CLI ເຊັ່ນ [mobiletto-cli](https://www.npmjs.com/package/mobiletto-cli),
333
- ທ່ານແນ່ນອນຕ້ອງການ redis cache ເປີດໃຊ້, ຍ້ອນວ່າມັນຈະແກ່ຍາວເຖິງການຮຽກຮ້ອງຂອງຄໍາສັ່ງ `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` ປະຕິບັດການສໍາເນົາຫນຶ່ງຄັ້ງຂອງໄຟລ໌ທັງຫມົດຈາກ mobiletto ຫນຶ່ງໄປຫາອື່ນ.
344
- ມັນບໍ່ໄດ້ດໍາເນີນຂະບວນການໃດໆເພື່ອຮັກສາກະຈົກໃນໄລຍະເວລາ. ດໍາເນີນການຄໍາສັ່ງ `mirror` ອີກເທື່ອຫນຶ່ງ
345
- ເພື່ອ synchronize ໄຟລ໌ໃດທີ່ຂາດຫາຍໄປ.
346
-
347
- ຄ່າກັບຄືນຈາກ `mirror` ແມ່ນວັດຖຸທີ່ງ່າຍດາຍທີ່ມີຕົວນັບສໍາລັບຈໍານວນໄຟລ໌ທີ່ປະສົບຜົນສໍາເລັດ
348
- mirrored ແລະຈໍານວນໄຟລ໌ທີ່ມີຂໍ້ຜິດພາດ:
349
-
350
- {
351
- success: count-of-files-mirrored,
352
- errors: count-of-files-with-errors
353
- }
354
-
355
- ຄໍາເຕືອນ: ການສະທ້ອນຊຸດຂໍ້ມູນຂະຫນາດໃຫຍ່ສາມາດໃຊ້ເວລາຫຼາຍແລະໃຊ້ແບນວິດຫຼາຍ.
356
-
357
- ດ້ວຍຄຳວ່າ `mirror` call semantics ມັນບາງຄັ້ງອາດສັບສົນທີ່ຈະເຂົ້າໃຈວ່າໃຜແມ່ນໃຜ
358
- ຜູ້ອ່ານແລະໃຜເປັນນັກຂຽນ. ຈິນຕະນາການມັນຄືກັບຄໍາຖະແຫຼງການມອບຫມາຍ: "ມືຖືຊ້າຍມື"
359
- ແມ່ນ​ສິ່ງ​ທີ່​ໄດ້​ຮັບ​ການ​ມອບ​ຫມາຍ​ໃຫ້ (ຂໍ້​ມູນ mirrored ລາຍ​ລັກ​ອັກ​ສອນ​)​, ແລະ "ຂວາ​ມື mobiletto​" (ໄດ້​
360
- argument ກັບວິທີການ `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
- ເກີດ​ຫຍັງ​ຂຶ້ນ? ໄດເຣັກທໍຣີ "ການເຂົ້າລະບົບ" ແຍກຕ່າງຫາກ (dirent) ໄດເລກະທໍລີ (ເຂົ້າລະຫັດ) ຕິດຕາມວ່າໄຟລ໌ໃດຢູ່ໃນນັ້ນ
383
- directory (aka the dirent directory).
384
- * ຄໍາສັ່ງ `list` ອ່ານໄຟລ໌ລາຍຊື່ໄດເລກະທໍລີ, ຖອດລະຫັດແຕ່ລະເສັ້ນທາງທີ່ລະບຸໄວ້; ຈາກນັ້ນສົ່ງຄືນ metadata ສໍາລັບແຕ່ລະໄຟລ໌
385
- * ຄໍາສັ່ງ `list` ແມ່ນບໍ່ມີປະສິດທິພາບຫຼາຍ, ໂດຍສະເພາະສໍາລັບໄດເລກະທໍລີທີ່ມີໄຟລ໌ຈໍານວນຫລາຍ
386
- * ຄໍາສັ່ງ `write` ຂຽນໄຟລ໌ dirent ໃນໄດເລກະທໍລີ dirent ຂອງພໍ່ແມ່ແຕ່ລະຄົນ, recursively; ຫຼັງຈາກນັ້ນຂຽນໄຟລ໌
387
- * ຄໍາ​ສັ່ງ `write` ຈະ​ເກີດ O(N​) writes​, ມີ N = ຄວາມ​ເລິກ​ໃນ​ລໍາ​ດັບ​ລະ​ບົບ
388
- * ຄໍາສັ່ງ `remove` ເອົາໄຟລ໌ dirent ທີ່ສອດຄ້ອງກັນ, ແລະພໍ່ແມ່ຂອງມັນຖ້າຫວ່າງເປົ່າ, recursively; ຈາກນັ້ນລຶບໄຟລ໌ອອກ
389
- * ຄໍາສັ່ງ `remove` ທີ່ບໍ່ແມ່ນ recursive ຈະເຮັດໃຫ້ເກີດ O(N) ອ່ານແລະອາດຈະເປັນການລຶບຈໍານວນຫຼາຍ, ດ້ວຍ N = ຄວາມເລິກໃນລໍາດັບຊັ້ນຂອງໄດເລກະທໍລີ.
390
- * ຄໍາສັ່ງ `remove` ຢູ່ໃນລະບົບໄຟລ໌ຂະຫນາດໃຫຍ່ແລະເລິກສາມາດມີລາຄາແພງ
391
-
392
- ໃຫ້ສັງເກດວ່າເຖິງແມ່ນວ່າການເຂົ້າລະຫັດຂ້າງລູກຄ້າໄດ້ຖືກເປີດໃຊ້, ສັດຕູທີ່ມີການເບິ່ງເຫັນຢ່າງເຕັມທີ່ເຂົ້າໄປໃນຝ່າຍເຊີຟເວີທີ່ຖືກເຂົ້າລະຫັດຂອງທ່ານ.
393
- ການເກັບຮັກສາ, ເຖິງແມ່ນວ່າບໍ່ມີກະແຈ, ຍັງສາມາດເຫັນຈໍານວນທັງຫມົດຂອງໄດເລກະທໍລີແລະຈໍານວນໄຟລ໌ຢູ່ໃນແຕ່ລະ, ແລະດ້ວຍ
394
- ຄວາມ​ພະ​ຍາ​ຍາມ​ບາງ​ຢ່າງ​, ຄົ້ນ​ພົບ​ບາງ​ຫຼື​ທັງ​ຫມົດ​ຂອງ​ໂຄງ​ປະ​ກອບ​ການ​ໂດຍ​ລວມ​ຂອງ​ລໍາ​ດັບ​ລະ​ບົບ​.
395
- *ໝາຍເຫດ: ໃຊ້ໂຄງສ້າງທີ່ຂ້ອນຂ້າງຮາບພຽງເພື່ອຄວາມປອດໄພທີ່ດີກວ່າ.*
396
- ສັດຕູຈະບໍ່ຮູ້ຈັກຊື່ຂອງໄດເລກະທໍລີ / ໄຟລ໌ເວັ້ນເສຍແຕ່ວ່າພວກເຂົາຮູ້ຈັກການເຂົ້າລະຫັດຂອງທ່ານ
397
- ຄີ ຫຼືມີການແຕກແຍກການເຂົ້າລະຫັດຢ່າງສຳເລັດຜົນ. ການເດີມພັນທັງໝົດແມ່ນປິດແລ້ວ!
398
-
399
- ### ປະສິດທິພາບແລະຖານຄວາມຈໍາ
400
- ການດໍາເນີນງານກ່ຽວກັບການເກັບຮັກສາທີ່ເຂົ້າລະຫັດອາດຈະຊ້າ. ລາຍຊື່ແລະການຖອນຄືນຄືນສາມາດຊ້າຫຼາຍ.
401
- Caching ຜ່ານ redis ຊ່ວຍຢ່າງຫຼວງຫຼາຍ, ແຕ່ສັງເກດວ່າ cache ຈະຖືກ flushed ເມື່ອຂຽນຫຼືເອົາອອກ.
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
- ໄດເວີແມ່ນໄຟລ໌ JS ທີ່ສົ່ງອອກຟັງຊັນ 'storageClient' ທີ່ມີລາຍເຊັນນີ້:
418
-
419
- function storageClient (key, secret, opts)
420
-
421
- * `key` : a string, API key (ສຳ​ລັບ `local` driver ນີ້​ແມ່ນ base directory)
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
- ຂອງລະດັບ `npm` ທີ່ກຳນົດໄວ້ໃນ [https://www.npmjs.com/package/winston#logging-levels](https://www.npmjs.com/package/winston#logging-levels)
465
-
466
- ລະດັບເລີ່ມຕົ້ນແມ່ນ `error` . ລະດັບ verbose ທີ່ສຸດແມ່ນ `silly` , ເຖິງແມ່ນວ່າໃນປັດຈຸບັນ mobiletto
467
- ບໍ່ໄດ້ບັນທຶກໃນລະດັບຂ້າງລຸ່ມນີ້ `debug`
468
-
469
- MOBILETTO_LOG_LEVEL=silly # maximum logs!
470
-
471
- ### ບັນທຶກໄຟລ໌
472
- ໂດຍຄ່າເລີ່ມຕົ້ນ, ຜູ້ຕັດໄມ້ຂຽນໃສ່ console. ເພື່ອສົ່ງບັນທຶກໄປຫາໄຟລ໌, ຕັ້ງຄ່າ `MOBILETTO_LOG_FILE`
473
- ສະພາບແວດລ້ອມປ່ຽນແປງ. ເມື່ອບັນທຶກໄຟລ໌, ບັນທຶກຈະບໍ່ຖືກຂຽນໃສ່ console ອີກຕໍ່ໄປ.
474
-
475
- MOBILETTO_LOG_FILE=/var/my_mobiletto_log
476
-
477
- ເພື່ອປິດການບັນທຶກ:
478
-
479
- MOBILETTO_LOG_FILE=/dev/null
480
-
481
- </pre>