{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/5308","repository_url":"https://api.github.com/repos/facebook/react-native","labels_url":"https://api.github.com/repos/facebook/react-native/issues/5308/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/5308/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/5308/events","html_url":"https://github.com/facebook/react-native/issues/5308","id":126649666,"number":5308,"title":"[Android] FormData fails to send data in multipart/form-data","user":{"login":"ashleydw","id":844437,"avatar_url":"https://avatars.githubusercontent.com/u/844437?v=3","gravatar_id":"","url":"https://api.github.com/users/ashleydw","html_url":"https://github.com/ashleydw","followers_url":"https://api.github.com/users/ashleydw/followers","following_url":"https://api.github.com/users/ashleydw/following{/other_user}","gists_url":"https://api.github.com/users/ashleydw/gists{/gist_id}","starred_url":"https://api.github.com/users/ashleydw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashleydw/subscriptions","organizations_url":"https://api.github.com/users/ashleydw/orgs","repos_url":"https://api.github.com/users/ashleydw/repos","events_url":"https://api.github.com/users/ashleydw/events{/privacy}","received_events_url":"https://api.github.com/users/ashleydw/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/react-native/labels/Android","name":"Android","color":"bfe5bf"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-01-14T12:57:07Z","updated_at":"2016-04-27T09:58:57Z","closed_at":"2016-01-25T08:26:56Z","body":"As per https://github.com/facebook/react-native/pull/1357#issuecomment-171378913 @philikon implemented uploading files (images) via the NetworkingModule.java. \r\n\r\nThe following works on iOS (image and description are sent to server and received correctly) on iOS. On Android, the request is made but both image and description are missing from the request.\r\n\r\n```\r\nlet formData = new FormData();\r\nformData.append('image', {uri: image.uri, type: 'image/jpg', name: 'image.jpg'});\r\nformData.append('description', String(data.description));\r\n\r\nlet options = {};\r\noptions.headers['Content-Type'] = 'multipart/form-data; boundary=6ff46e0b6b5148d984f148b6542e5a5d';\r\noptions.body = formData;\r\nreturn fetch(uri, options).then((response) => {\r\n   .... \r\n});\r\n```\r\n\r\nWhere `image.uri` is either an android or ios file:\r\n\r\n* android: `file:///storage/emulated/0/Pictures/eb645893-4c00-44a3-a9b4-a2116e955f7c.jpg`\r\n* ios: `/Users/ashleydw/Library/Developer/CoreSimulator/Devices/23EE88D0-6E91-43AD-A3B6-06F87698C5A8/data/Containers/Data/Application/A73E68D3-7424-4301-9934-AD0F8251C1EB/tmp/7803DA8A-0E40-4FCB-A593-884805878172.jpg`\r\n\r\nI've tried both with and without it `file://`. Without it, the NetworkingModule.java reaches \"Could not retrieve file for uri /storage/emulated/0/Pictures/8505b7c8-389e-4a0a-8d0a-7669891031f9.jpg\" on line https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java#L166.\r\n\r\nWith it, the requests send but the data is missing.\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/215036161","html_url":"https://github.com/facebook/react-native/issues/5308#issuecomment-215036161","issue_url":"https://api.github.com/repos/facebook/react-native/issues/5308","id":215036161,"user":{"login":"oney","id":4091190,"avatar_url":"https://avatars.githubusercontent.com/u/4091190?v=3","gravatar_id":"","url":"https://api.github.com/users/oney","html_url":"https://github.com/oney","followers_url":"https://api.github.com/users/oney/followers","following_url":"https://api.github.com/users/oney/following{/other_user}","gists_url":"https://api.github.com/users/oney/gists{/gist_id}","starred_url":"https://api.github.com/users/oney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oney/subscriptions","organizations_url":"https://api.github.com/users/oney/orgs","repos_url":"https://api.github.com/users/oney/repos","events_url":"https://api.github.com/users/oney/events{/privacy}","received_events_url":"https://api.github.com/users/oney/received_events","type":"User","site_admin":false},"created_at":"2016-04-27T09:58:57Z","updated_at":"2016-04-27T09:58:57Z","body":"```javascript\r\nlet xhr = new XMLHttpRequest();\r\nxhr.open('POST', this.baseUrl + '/mobileapi/user/picture');\r\nxhr.setRequestHeader('content-type', 'multipart/form-data');\r\nlet formdata = new FormData();\r\n// image from CameraRoll.getPhotos(\r\nformdata.append('image', {...image, name: 'image.jpg', type: 'multipart/form-data'});\r\nxhr.send(formdata);\r\n```\r\nThis works on Android"}}