@ exodus/ storage- 移动
当地具体执行《公约》的情况 统一存储光谱 移动应用程序.
[大 很可能你应该使用
@exodus/adapters-mobile换句话说, 这将为您配置它.
安装
pnpm add @exodus/storage-mobile
使用量
使用模块调用工厂并传递所需的依赖
import { hashSync } from '@exodus/crypto/hash'
import createStorageMobile from '@exodus/storage-mobile'
import AsyncStorage from '@exodus/react-native-async-storage'
import fs from '@exodus/react-native-fs'
const hashString = (str) => hashSync('sha256', str, 'hex').slice(0, 20)
const storage = createStorageMobile({
asyncStorage: AsyncStorage,
androidFallback: {
filesystem: {
rimraf: fs.unlink.bind(fs),
mkdirp: fs.mkdir.bind(fs),
readUtf8: fs.readUtf8.bind(fs),
writeUtf8: fs.writeUtf8.bind(fs),
},
placeholder: '~', // will be written to the async storage for files larger than the threshold
rootDir: fs.DocumentDirectoryPath + '/async-storage',
hashString,
threshold: 1.9 * 1024 * 1024, // JSON-serialized UTF-8 bytes, below Android's 2 MiB row limit
},
})
// use as any other `@exodus/storage-spec` compliant interface