v0.21.4 Fix coding oversight for image upload handling
This commit is contained in:
parent
aff0c90976
commit
69611ee3b5
@ -1,5 +1,5 @@
|
|||||||
# gossamer threads migration-import code
|
# gossamer threads migration-import code
|
||||||
# v0.21.3
|
# v0.21.4
|
||||||
|
|
||||||
require 'mysql2'
|
require 'mysql2'
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
@ -300,10 +300,10 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Helper method to upload an attachment / image to Discourse
|
# Helper method to upload an attachment / image to Discourse
|
||||||
def upload_attachment(user, file, filename, gossamer_url)
|
def upload_attachment(user_id, file, filename, gossamer_url)
|
||||||
begin
|
begin
|
||||||
upload = Upload.create!(
|
upload = Upload.create!(
|
||||||
user_id: user.id,
|
user_id: user_id,
|
||||||
original_filename: filename,
|
original_filename: filename,
|
||||||
filesize: file.size,
|
filesize: file.size,
|
||||||
# filesize: File.size(file.path),
|
# filesize: File.size(file.path),
|
||||||
@ -320,7 +320,7 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
upload.save!
|
upload.save!
|
||||||
upload
|
upload
|
||||||
rescue => e
|
rescue => e
|
||||||
puts "Failed to upload attachment #{filename} for user #{user.username}: #{e.message}"
|
puts "Failed to upload attachment #{filename} for user_id #{user_id}: #{e.message}"
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user