当我通过邮递员将图像发布到S3时,我的Rails API似乎运行良好。 但是,当我使用React Native图像选择器时,我认为我没有以正确的方式发送参数。
我当前正在发送图像uri作为图像参数(从图像选择器中拾取的图像的uri)。我是否应该发送其他内容作为image参数?
这是我向Visions表发出POST请求的异步功能的一部分:
let access_token = this.state.accessToken
try {
let response = await fetch('https://prana-app.herokuapp.com/v1/visions/', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-User-Email': this.state.email,
'X-User-Token': this.state.accessToken
},
body: JSON.stringify({
vision: {
description: 'YOYOYOYOYO',
image: this.state.uploadFile
}
})
});
在这种情况下,this.state.uploadfile是从图像选择器中选择图像时得到的response.uri
,其格式如下:
file:///Users/ozgecokyasar/Library/Developer/CoreSimulator/Devices/EDD6C498-DACD-433E-B96D-3A30BAE7BA6D/data/Containers/Data/Application/B549F09A-EB40-4D9A-B8A8-B003362BE49D/Library/Caches/ExponentExperienceData/%2540anonymous%252Fmanifestation-react-3ac1cbe2-549f-49e7-8506-ef29638d1643/ImagePicker/28EAA390-F814-4A80-A188-8592B642BEFA.jpg
我遇到500错误:
ActionView :: Template :: Error(to_model委托给附件,但附件为nil):