react原生邮件:安卓v11的应用程序因附件而崩溃



我在React Native应用程序中使用react-native-mail。这是我的代码:

const path = RNFetchBlob.fs.dirs.CacheDir + '/' + SHA1(this.fileSource.uri) + '.pdf'
const self = this;
let data = this.fileSource.uri.replace(/data:application/pdf;base64,/i, '');
RNFetchBlob.fs
.writeFile(path, data, 'base64')
.then(() => {
Mailer.mail({
subject: "Subject",
body: "",
recipients: [this.props.emailAddress],
attachment: {
path: path,
type: 'pdf',
name: `attachment.pdf`,
}
}, (error) => {
...
});
})
.catch(() => {
...
})

path的值为"/data/user/0/com.<my-app-name>/cache/5cae2ea1e235873729dd158e19f3d122a1b46c73.pdf"

data的值为TIAoxIDAgb2JqIAo8PCAKL1R5cGUgL0NhdGFsb2cgCi9QYWdlcyAyIDAgUiAKL1BhZ2VNb...(超长(

mail()方法抛出错误Failed to find configured root that contains /data/user/0/com.<my-app-name>/cache/5cae2ea1e235873729dd158e19f3d122a1b46c73.pdf

Android version: 11
react-native: 0.63.4
rn-fetch-blob: 0.12.0
react-native-mail: git+https://github.com/marcinolek/react-native-mail.git

有人知道我该怎么做吗?

尝试更改外部路径上的文件位置。

相关内容

  • 没有找到相关文章

最新更新