+ if respond_to?(:attachment_options) && attachment_options[:partition] == false
+ args
+ elsif attachment_options[:uuid_primary_key]
+ # Primary key is a 128-bit UUID in hex format. Split it into 2 components.
+ path_id = attachment_path_id.to_s
+ component1 = path_id[0..15] || "-"
+ component2 = path_id[16..-1] || "-"
+ [component1, component2] + args
+ else
+ path_id = attachment_path_id
+ if path_id.is_a?(Integer)
+ # Primary key is an integer. Split it after padding it with 0.
+ ("%08d" % path_id).scan(/..../) + args
+ else
+ # Primary key is a String. Hash it, then split it into 4 components.
+ hash = Digest::SHA512.hexdigest(path_id.to_s)
+ [hash[0..31], hash[32..63], hash[64..95], hash[96..127]] + args
+ end
+ end