[英]Issue using Relay mutations with files
I have an issue using File Mutation with Relay. 我在中继中使用文件突变时遇到问题。 I am trying to create a mutation using getFiles()
我正在尝试使用getFiles()创建一个突变
Relay.Store.commitUpdate(
new AddOrderMutation({userId: userId, medications: OrderInputTypeMedication,
userAddressId:userAddressId,files:files}),
{
onSuccess: (response) => OnResponseSuccess(response),
onFailure: (transaction,e) => console.log('transaction',transaction.getError(),'e',e),
},
);
} }
I always get an error that said transaction TypeError: Network request failed at XMLHttpRequest.xhr.onerror (D:\\ReactNative\\MedexApp\\node_modules\\react-native\\node_modules\\whatwg-fetch\\fetch.js:436)
although all other requests are working good. 我总是收到一个表示
transaction TypeError: Network request failed at XMLHttpRequest.xhr.onerror (D:\\ReactNative\\MedexApp\\node_modules\\react-native\\node_modules\\whatwg-fetch\\fetch.js:436)
的错误transaction TypeError: Network request failed at XMLHttpRequest.xhr.onerror (D:\\ReactNative\\MedexApp\\node_modules\\react-native\\node_modules\\whatwg-fetch\\fetch.js:436)
尽管所有其他请求都是工作很好。 also the same mutation is sent correctly without attaching any files. 也可以正确发送相同的变异而无需附加任何文件。 this is the array of files
["1489322712989.jpg":{filename:"1489322712989.jpg" uri:"file:///storage/emulated/0/Pictures/1489322712989.jpg"}]
and It never sends the request through fiddler or caught in the webservice 这是文件
["1489322712989.jpg":{filename:"1489322712989.jpg" uri:"file:///storage/emulated/0/Pictures/1489322712989.jpg"}]
,它永远不会通过发送请求提琴手或陷入网络服务
I wasn't adding to the Files Object (type: 'image/jpg'), so the file Object should be as follows: 我没有添加到文件对象(类型:“图像/ jpg”),因此文件对象应如下所示:
file ={
uri: this.state.image.uri,
name: this.state.image.name,
type:'image/jpg'
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.