react-native-fs icon indicating copy to clipboard operation
react-native-fs copied to clipboard

How do I add headers onto a download request?

Open vince-rowe opened this issue 10 years ago • 2 comments

Using react native 0.26 and react-native-fs 1.4 I need to pass authentication headers / tokens to a download request for files, I can't see how I would do that by calling:

downloadFile(fromUrl, toFile, begin, progress) {.. etc

My context is I'm using this to grab a PDF for display in Android via https://github.com/cnjon/react-native-pdf-view

Can someone advise?

Many thanks, Vince

vince-rowe avatar Jun 01 '16 11:06 vince-rowe

@vince-rowe At the moment, you can't I'm afraid. I intend to make the signature for downloadFile more like uploadFile so that it can have more optional parameters (such as headers). We can support the old parameters by inspecting the argument length. Will be a few days before I get a moment to implement this though.

cjdell avatar Jun 01 '16 14:06 cjdell

@vince-rowe The method downloadFile now supports setting custom HTTP headers. Please see updated readme.

cjdell avatar Jun 03 '16 23:06 cjdell