-
Notifications
You must be signed in to change notification settings - Fork 501
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
use POST for file download to avoid url length limits #6957
Conversation
Thanks @qqmyers we'll take a look. As you mentioned, those failing tests are failing on develop, so makes sense they are failing here as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments about docs and error handling. I deployed the code and it seemed to work fine on two files.
@Produces({ "application/zip" }) | ||
public Response postDownloadDatafiles(String fileIds, @QueryParam("gbrecs") boolean gbrecs, @QueryParam("key") String apiTokenParam, @Context UriInfo uriInfo, @Context HttpHeaders headers, @Context HttpServletResponse response) throws WebApplicationException { | ||
|
||
fileIds = fileIds.substring(8); // String "fileIds=" from the front |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was playing with this using curl and got a NullPointerException when fileIds
was null (and a 500 error). Some error checking would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is error checking. I just defeated it by taking a substring of null before the error check is done in downloadDataFiles() :-) Will fix.
// TODO: Rather than only supporting looking up files by their database IDs, | ||
// consider supporting persistent identifiers. | ||
@Path("datafiles") | ||
@POST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this API should be documented along side the other ones in the Data Access API page of the API Guide. I can imagine the same error that was reported in #6943 could easily happen to API users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added - feel free to change.
} catch (IOException ex) { | ||
logger.info("Failed to issue a redirect to file download url."); | ||
} | ||
PrimeFaces.current().executeScript("downloadFiles('"+fileDownloadUrl + "','"+ multiFileString+"');"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a comment but I assume that PrimeFaces is being used here because there's no JSF standard way (FacesContext way) to execute a script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not certain but this is done elsewhere and I assume PF needed this method for some reason. I didn't find anything else with a quick web check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What this PR does / why we need it: uses POST for file download requests, avoiding problems with limits on the url length for requests for large numbers of files
Which issue(s) this PR closes:
Closes #6943
Special notes for your reviewer: We've used this on QDR since last May, but I just tried to compare with that fork to pull things over - haven't tested this commit.
Suggestions on how to test this: Nominally, if any download works, this is working. To verify that it's better than the prior code, you'll need to have enough files to have caused trouble. That was 1061 in the issue but I'd suggest a larger number for a test or make sure your test DB uses ids with the same number of digits because the issue is line length and ids in production will be longer than on a new test machine starting with id 1.
Does this PR introduce a user interface change? If mockups are available, please link/include them here: No
Is there a release notes update needed for this change?: No
Additional documentation: