8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/zendesk_api/middleware/request/upload.rb', line 8
def call(env)
if env[:body] && env[:body][:file]
file = env[:body].delete(:file)
case file
when File
path = file.path
when String
path = file
else
warn "WARNING: Passed invalid filename #{file} of type #{file.class} to upload"
end
if path
env[:body][:filename] ||= File.basename(path)
mime_type = MIME::Types.type_for(path).first || "application/octet-stream"
env[:body][:uploaded_data] = Faraday::UploadIO.new(path, mime_type)
end
end
@app.call(env)
end
|