react-native - 无法使用放大将文件从 React Native 上传到 S3
问题描述
我尝试使用以下代码将文件上传到 S3 Bucket
RNFS.readFile(this.state.photo.uri, 'base64').then((res) => {
Storage.put(filename, base64.decode(res)).then((stored) => {
console.log('stored', JSON.stringify(stored))
}).catch(err => {
console.log(err)
});
}).catch(err => console.log(err))
它给了我 AWSS3Provider - error uploading [Error: Request failed with status code 403]。
但是如果我删除 base64.decode(res) 并运行下面的代码,它会在 S3 上上传一个文件{这个文件没有打开}
RNFS.readFile(this.state.photo.uri, 'base64').then((res) => {
Storage.put(filename, res).then((stored) => {
console.log('stored', JSON.stringify(stored))
}).catch(err => {
console.log(err)
});
}).catch(err => console.log(err))
我必须将图像/视频直接从移动应用{React-Native} 上传到 AWS S3。
解决方案
推荐阅读
- c# - 从子视图 mvvm 返回数据
- python - .split 在链接 .replace 方法时给出列表中的空元素
- swift - 我无法在我的应用程序中创建新帐户。创建帐户按钮不执行任何操作
- c++ - 使用 SFML 在屏幕顶部绘制 (Windows)
- sql-server - 将 SchemaSpy 连接到 Linux for Docker Engine 上的 Microsoft SQL Server 失败并显示连接失败
- javascript - JSON.parse() 给出错误。需要排除故障
- reactjs - 如何正确转译 JSX
- python - python中设置的cs50信用问题的解决方案
- javascript - Object.keys 在 IE11 中工作的解决方法是什么?
- salt-stack - 如何从盐矿中盐用户的主目录读取文件