I want to upload an image to dropbox using their API with http in flutter but dropbox API content-type is 'application/octet-stream', when I tried using http content-type like this(appplication/json) but not working, How can I use this application/octet-stream as my Http content type in flutter
2 Answers
Try to do something like this:
http.post(url,
headers: {"Content-Type": "application/octet-stream"},
body: your-image-data
-
I have a lot of headers so, I have to use Map. like this Map<String, String> requestHeaders = { 'Content-type': 'application/octet-stream', 'User-Agent': 'api-explorer-client', // 'Dropbox-API-Arg': '{"path": "/EasyBay/Project1/image.txt"}', 'Authorization': 'Bearer' + token }; Yet, It's not working. Commented Aug 29, 2019 at 8:41
in dio
Dio dio = Dio()..interceptors.add(InterceptorsWrapper(
onRequest: (RequestOptions options) async {
options.headers
..addAll({
'platform': 'xxxx',
'token': 'xxx'
});
return options;
}
))