Store avatars as binary instead of base64
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -5,12 +5,12 @@ module LdapManager
|
||||
end
|
||||
|
||||
def call
|
||||
treebase = ldap_config["base"]
|
||||
treebase = ldap_config["base"]
|
||||
attributes = %w{ jpegPhoto }
|
||||
filter = Net::LDAP::Filter.eq("cn", @cn)
|
||||
filter = Net::LDAP::Filter.eq("cn", @cn)
|
||||
|
||||
entry = client.search(base: treebase, filter: filter, attributes: attributes).first
|
||||
entry.try(:jpegPhoto) ? entry.jpegPhoto.first : nil
|
||||
entry&.jpegPhoto ? entry.jpegPhoto.first : nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,20 +8,20 @@ module LdapManager
|
||||
end
|
||||
|
||||
def call
|
||||
replace_attribute @dn, :jpegPhoto, @img_data
|
||||
result = replace_attribute @dn, :jpegPhoto, @img_data
|
||||
result
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def process(file)
|
||||
processed = ImageProcessing::Vips
|
||||
.resize_to_fill(512, 512)
|
||||
.resize_to_fill(256, 256)
|
||||
.source(file)
|
||||
.convert("jpeg")
|
||||
.saver(strip: true)
|
||||
.call
|
||||
|
||||
Base64.strict_encode64 processed.read
|
||||
processed.read
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user