39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/active_storage/service/cloudinary_service.rb', line 39
def upload(key, io, filename: nil, checksum: nil, **options)
instrument :upload, key: key, checksum: checksum do
begin
= checksum.nil? ? {} : {::CONTENT_MD5 => checksum}
options = @options.merge(options)
resource_type = resource_type(io, key)
options[:format] = ext_for_file(key) if resource_type == "raw"
Cloudinary::Uploader.upload_large(
io,
public_id: public_id_internal(key),
resource_type: resource_type,
context: {active_storage_key: key, checksum: checksum},
extra_headers: ,
**options
)
rescue CloudinaryException => e
raise ActiveStorage::IntegrityError, e.message, e.backtrace
end
end
end
|