#5649 Fix FileAlreadyExistsException when downloading file using jersey2 (#5654)

* #5649 Fix download file copy

* Include generated pet store samples and fix indentation

* Regenerate petstore sample to fix indentation
This commit is contained in:
Harald Walker
2017-05-18 09:12:53 +02:00
committed by wing328
parent 07df7d47eb
commit 4417bb6b32
6 changed files with 8 additions and 2 deletions

View File

@@ -25,6 +25,7 @@ import java.io.InputStream;
{{^supportJava6}}
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
{{/supportJava6}}
{{#supportJava6}}
import org.apache.commons.io.FileUtils;
@@ -581,7 +582,7 @@ public class ApiClient {
try {
File file = prepareDownloadFile(response);
{{^supportJava6}}
Files.copy(response.readEntity(InputStream.class), file.toPath());
Files.copy(response.readEntity(InputStream.class), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
{{/supportJava6}}
{{#supportJava6}}
// Java6 falls back to commons.io for file copying

View File

@@ -0,0 +1 @@
2.2.3-SNAPSHOT

View File

@@ -16,6 +16,7 @@ package io.swagger.client.model;
import org.apache.commons.lang3.ObjectUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;

View File

@@ -0,0 +1 @@
2.2.3-SNAPSHOT

View File

@@ -24,6 +24,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
@@ -575,7 +576,7 @@ public class ApiClient {
public File downloadFileFromResponse(Response response) throws ApiException {
try {
File file = prepareDownloadFile(response);
Files.copy(response.readEntity(InputStream.class), file.toPath());
Files.copy(response.readEntity(InputStream.class), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
return file;
} catch (IOException e) {
throw new ApiException(e);

View File

@@ -16,6 +16,7 @@ package io.swagger.client.model;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;