Skip to content
This repository has been archived by the owner on Nov 25, 2023. It is now read-only.

Commit

Permalink
Write image to img/icons
Browse files Browse the repository at this point in the history
  • Loading branch information
sue445 committed Nov 25, 2023
1 parent 8653b62 commit b8c975e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ruby/app.rb
Expand Up @@ -798,7 +798,15 @@ def fill_user_response(tx, user_model)
icon_id = db_transaction do |tx|
tx.xquery('DELETE FROM icons WHERE user_id = ?', user_id)
tx.xquery('INSERT INTO icons (user_id, image) VALUES (?, ?)', user_id, image)
tx.last_id
id = tx.last_id

# iconsにも保存する
user = tx.xquery("SELECT name FROM users WHERE id = ?", user_id).first
File.open("#{ICONS_DIR}/#{user[:name]}.jpg", 'wb') do |f|
f.write(image)
end

id
end

status 201
Expand Down

0 comments on commit b8c975e

Please sign in to comment.