6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/tableau_server_client/resources/downloadable.rb', line 6
def download(file_path: nil)
return @content_body if @content_body and (file_path.nil? or @file_path == file_path)
@file_path = file_path
response = client.download(location(query_params: {"includeExtract": "False"}), file_path: file_path)
content_type = response.['content-type']
case content_type
when 'application/xml'
return @content_body = Nokogiri::XML(response.body)
when 'application/octet-stream'
Zip::InputStream.open(StringIO.new(response.body)) do |io|
while entry = io.get_next_entry
return @content_body = Nokogiri::XML(io.read) if entry.name =~ /.*\.(tds|twb)/
end
raise "TDS or TWB file not found for: #{location.path}"
end
else
raise "Unknown content-type: #{content_type}"
end
end
|