23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'activestorage/lib/active_storage/attached/changes/create_one.rb', line 23
def upload
case attachable
when ActionDispatch::Http::UploadedFile
blob.upload_without_unfurling(attachable.open)
when Rack::Test::UploadedFile
blob.upload_without_unfurling(
attachable.respond_to?(:open) ? attachable.open : attachable
)
when Hash
blob.upload_without_unfurling(attachable.fetch(:io))
when File
blob.upload_without_unfurling(attachable)
when Pathname
blob.upload_without_unfurling(attachable.open)
when ActiveStorage::Blob
when String
else
raise(
ArgumentError,
"Could not upload: expected attachable, " \
"got #{attachable.inspect}"
)
end
end
|