Store avatars as binary instead of base64
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-01-24 15:56:34 +03:00
parent 6d7d722c5d
commit 9e2210c45b
5 changed files with 35 additions and 24 deletions

View File

@@ -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

View File

@@ -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