Support looser format when detecting filename

This commit is contained in:
xhh 2015-06-25 16:26:04 +08:00
parent ceafbcc97f
commit e6e1db2064
2 changed files with 2 additions and 2 deletions

View File

@ -95,7 +95,7 @@ module {{moduleName}}
tmp_file = Tempfile.new '', Swagger.configuration.temp_folder_path tmp_file = Tempfile.new '', Swagger.configuration.temp_folder_path
content_disposition = raw.headers['Content-Disposition'] content_disposition = raw.headers['Content-Disposition']
if content_disposition if content_disposition
filename = content_disposition[/filename="([^"]+)"/, 1] filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
path = File.join File.dirname(tmp_file), filename path = File.join File.dirname(tmp_file), filename
else else
path = tmp_file.path path = tmp_file.path

View File

@ -95,7 +95,7 @@ module SwaggerClient
tmp_file = Tempfile.new '', Swagger.configuration.temp_folder_path tmp_file = Tempfile.new '', Swagger.configuration.temp_folder_path
content_disposition = raw.headers['Content-Disposition'] content_disposition = raw.headers['Content-Disposition']
if content_disposition if content_disposition
filename = content_disposition[/filename="([^"]+)"/, 1] filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
path = File.join File.dirname(tmp_file), filename path = File.join File.dirname(tmp_file), filename
else else
path = tmp_file.path path = tmp_file.path