New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIBZ-2453: Kinvey.Files.downloadByUrl should call the error function if the server returns an error #333

Merged
merged 2 commits into from Jul 25, 2018

Conversation

Projects
None yet
2 participants
@thomasconner
Contributor

thomasconner commented Jul 23, 2018

Description

Steps To Reproduce:

  1. Stream a file with ttl = 0:
Kinvey.Files.download(fileId, { stream: true, ttl: 0 });
  1. Try to download the file using the expired __downloadURL_:
Kinvey.Files.downloadByUrl(result._downloadURL);

Expected Result: The error function is called with the error from the server.
Actual Result: The success function is called with a string, containing an XML from the server:

<?xml version='1.0' encoding='UTF-8'?><Error><Code>ExpiredToken</Code><Message>The provided token has expired.</Message><Details>Request has expired: 1523979099</Details></Error>

Changes

  • Reject with error from Network response.
  • Only send X-Kinvey-Device-Information header to a kinvey.com endpoint.
MIBZ-2453: Reject with error from Network response
Only send X-Kinvey-Device-Information header to a kinvey.com endpoint

@thomasconner thomasconner self-assigned this Jul 23, 2018

@thomasconner thomasconner requested a review from vinaygahlawat Jul 23, 2018

headers['X-Kinvey-Device-Information'] = deviceInformation(this.pkg);
if (kinveyUrlRegex.test(url)) {
// Add the X-Kinvey-Device-Information header
headers['X-Kinvey-Device-Information'] = deviceInformation(this.pkg);

This comment has been minimized.

@vinaygahlawat

vinaygahlawat Jul 24, 2018

Contributor

How is the setting of the X-Kinvey-Device-Information header related to the issue of calling success when an error is returned from the backend?

This comment has been minimized.

@thomasconner

thomasconner Jul 24, 2018

Contributor

I was getting errors where Google was reject the GET request because of the X-Kinvey-Device-Information header. It was not causing the issue but it was preventing me from testing. I went ahead and made the change here.

@thomasconner thomasconner merged commit 928895a into master Jul 25, 2018

@thomasconner thomasconner deleted the MLIBZ-2453_Fix_File_Downloads branch Jul 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment