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

Download a URL with no name or content disposition headers #840

Closed
fyrewall77 opened this Issue Oct 19, 2018 · 1 comment

Comments

Projects
None yet
3 participants
@fyrewall77

fyrewall77 commented Oct 19, 2018

The problem

Trying to download this image:
https://utdirect.utexas.edu/apps/pts/parking/citations/nlogon/images/6584836/
but the File it tries to download to is the reports directory, not a file inside the reports directory.

Details

Looks like this URL doesnt have a file name, nor does the server return a content disposition header.

Expected result

Some random File in the reports directory, not an exception.

Tell us about your environment

  • Selenide Version: 4.14.2

Code To Reproduce Issue [ Good To Have ]

Configuration.reportsFolder = "/tmp";
Selenide.download("https://utdirect.utexas.edu/apps/pts/parking/citations/nlogon/images/6584836/");

Bug location:
in DownloadFileWithHttpRequest.getFileName(), you make a call to FilenameUtils.getName(fileToDownloadLocation). which gets the name of the file from the end of the url. The URL specified in this enable has no file, so the resulting File is simply the reports directory. Whatever the file returned from here should not exist yet.

Change Requested:

if(fullFileName.isEmpty()) {
  return UUID.generate.tostring?;
}

OR

File target = FileUtils.createRandomFile();
Selenide.download("https://utdirect.utexas.edu/apps/pts/parking/citations/nlogon/images/6584836/", target);

@asolntsev asolntsev self-assigned this Nov 4, 2018

@asolntsev asolntsev added this to the 5.0.1 milestone Nov 4, 2018

@asolntsev

This comment has been minimized.

Contributor

asolntsev commented Nov 4, 2018

@fyrewall77 Thank you for reporting the issue! We will fix it in next release.

@asolntsev asolntsev added the bug 🐛 label Nov 4, 2018

asolntsev added a commit that referenced this issue Nov 7, 2018

asolntsev added a commit that referenced this issue Nov 7, 2018

@rosolko rosolko modified the milestones: 5.0.1, 5.0.2 Nov 8, 2018

@rosolko rosolko closed this Nov 8, 2018

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