1

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

1

2 Answers 2

2

Try to do something like this:

http.post(url,
  headers: {"Content-Type": "application/octet-stream"},
  body: your-image-data
1
  • 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
1

in dio

Dio dio = Dio()..interceptors.add(InterceptorsWrapper(
  onRequest: (RequestOptions options) async {
    options.headers
      ..addAll({
        'platform': 'xxxx',
        'token': 'xxx'
      });
    return options;
  }
))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.