When trying to download a file using your example code below, it fails without an exception if the file already exists.
File f = Unirest.get("http://mysite.com/mypic.jpg").asFile("mypic.jpg").getBody();
I use Java's File.createTempFile() method to create a unique tmp filename but since java creates an empty file as placeholder, when I pass that filename to asFile() it fails silently.
The problem seems to be in FileResponse.java, line 43 Files.copy(content, target); should be replaced with Files.copy(content, target,StandardCopyOption.REPLACE_EXISTING);
Of-course you should provide an option for this e.g. asFile(String path, boolean overwrite)
When trying to download a file using your example code below, it fails without an exception if the file already exists.
File f = Unirest.get("http://mysite.com/mypic.jpg").asFile("mypic.jpg").getBody();
I use Java's
File.createTempFile()
method to create a unique tmp filename but since java creates an empty file as placeholder, when I pass that filename toasFile()
it fails silently.The problem seems to be in FileResponse.java, line 43
Files.copy(content, target);
should be replaced withFiles.copy(content, target,StandardCopyOption.REPLACE_EXISTING);
Of-course you should provide an option for this e.g.
asFile(String path, boolean overwrite)