Class: TableauRestApi::Upload

Inherits:
Object
  • Object
show all
Defined in:
lib/tableau_rest_api/util/upload.rb

Instance Method Summary collapse

Constructor Details

#initialize(metadata, payload, boundary) ⇒ Upload

Returns a new instance of Upload.



3
4
5
6
7
# File 'lib/tableau_rest_api/util/upload.rb', line 3

def initialize(, payload, boundary)
   = 
  @payload = payload
  @boundary = boundary
end

Instance Method Details

#build(obj = :workbook) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tableau_rest_api/util/upload.rb', line 9

def build(obj=:workbook)
  "    --\#{@boundary}\\r\n    Content-Disposition: name=\"request_payload\"\\r\n    Content-Type: text/xml\\r\n    \\r\n    <tsRequest>\\r\n      <\#{obj} name=\"\#{@metadata[:name]}\">\\r\n        <project id=\"\#{@metadata[:project]}\"/>\\r\n      </\#{obj}>\\r\n    </tsRequest>\\r\n    --\#{@boundary}\\r\n    Content-Disposition: name=\"tableau_\#{obj}\"; filename=\"\#{@payload[:filename]}\"\\r\n    Content-Type: application/octet-stream\\r\n    \\r\n    \#{@payload[:data]}\\r\n    --\#{@boundary}--\\r\n  END\nend\n"