wag*_*gng 1 amazon-s3 amazon-web-services react-native
我将使用 React Native 在 Amazon S3 上上传图像。
我有 S3 signedUrl 用于上传图像。
如何在 React Native 中使用此 url 上传图像?
如果有人试过这个,请帮助我。
谢谢!
小智 5
很简单,我花了很多时间才发现:
const xhr = new XMLHttpRequest()
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
// success
} else {
// failure
}
}
}
xhr.open('PUT', presignedUrl)
xhr.setRequestHeader('Content-Type', fileType)
xhr.send({ uri: filePath, type: fileType, name: fileName })
Run Code Online (Sandbox Code Playgroud)
来源:http : //blog.rudikovac.com/react-native-upload-any-file-to-s3-with-a-presigned-url/
| 归档时间: |
|
| 查看次数: |
2865 次 |
| 最近记录: |