Remove path delimiters from downloading filename

This commit is contained in:
xhh 2016-01-11 22:13:07 +08:00
parent 3099aa2d85
commit 3c6639b4f6
2 changed files with 7 additions and 5 deletions

View File

@ -724,8 +724,9 @@ public class ApiClient {
// Get filename from the Content-Disposition header.
Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
Matcher matcher = pattern.matcher(contentDisposition);
if (matcher.find())
filename = matcher.group(1);
if (matcher.find()) {
filename = matcher.group(1).replaceAll(".*[/\\\\]", "");
}
}
String prefix = null;

View File

@ -141,8 +141,8 @@ public class ApiClient {
// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>();
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
authentications.put("petstore_auth", new OAuth());
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
}
@ -723,8 +723,9 @@ public class ApiClient {
// Get filename from the Content-Disposition header.
Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
Matcher matcher = pattern.matcher(contentDisposition);
if (matcher.find())
filename = matcher.group(1);
if (matcher.find()) {
filename = matcher.group(1).replaceAll(".*[/\\\\]", "");
}
}
String prefix = null;