The library we use (node-fetch) does not strip Authorization header when doing a redirect to a different host.
This lead to the following issue:
... doc .fetchBlob() .then(res => { debug('Downloaded asset', res); res.body.pipe(fs.createWriteStream(local_path)); }) .catch(err => { error('File save err: ', err); });
If that code redirects to s3 for instance, we end up with a 400
<?xml version="1.0" encoding="UTF-8"?> <Error><Code>InvalidArgument</Code><Message>Only one auth mechanism allowed; only the X-Amz-Algorithm query parameter, Signature query string parameter or the Authorization header should be specified</Message><ArgumentName>Authorization</ArgumentName><ArgumentValue>Basic XXXX</ArgumentValue><RequestId>XXXX</RequestId><HostId>XXXX=</HostId></Error>
What could be tried:
- Use https://github.com/npm/node-fetch-npm instead, as they handle the strip of Authorization header. See https://github.com/npm/node-fetch-npm/pull/2
- See how https://github.com/axios/axios handle that use case
- is related to
-
NXMOB-390 File download error on Android
- Resolved