Skip to content

Instantly share code, notes, and snippets.

@webdevlasse
Created April 18, 2014 16:27
Show Gist options
  • Save webdevlasse/11052635 to your computer and use it in GitHub Desktop.
Save webdevlasse/11052635 to your computer and use it in GitHub Desktop.
file_storage.rb
lines 42-58,
def update_file!(name, sid)
sid = sid.to_i
file_will_change!
raw_write_attribute(:file, name)
if (sid > 0) && (self.storage.id != sid)
# see if the item is right
if item.storage.id == sid
self.storage_id = nil
self.storage_configuration = nil
else
self.storage.id = sid
self.storage_configuration = StorageConfiguration.find(sid)
end
end
save!
end
in line 15 above the code was self.storage_id = sid but had to be changed to storage.id.
I believe this was possibly due to the rails upgrade. No matter. We can now upload to IA correctly. THe main image will upload but not the thumbnail.
MAIN FILE ON IA: http://archive.org/download/chunky6-carolco-and-studio-mp3.RBRWoh.popuparchive.org/IMG_0005.JPG
THUMB FILE ON IA : http://archive.org/download/chunky6-carolco-and-studio-mp3.RBRWoh.popuparchive.org/thumb_IMG_0005.JPG
I am wondering if you have any insight. I am currently following the idea that the save_thumb_version method's execution should come before copy_to_item_storage in this code:
in image_file.rb 39-48
def file_uploaded(file_name)
update_attributes(:is_uploaded => true, :file => file_name)
upload_id = upload_to.id
update_file!(file_name, upload_id)
# now copy it to the right place if it needs to be (e.g. s3 -> ia)
# or if it is in the right spot, process it!
copy_to_item_storage
save_thumb_version
# logger.debug "Tasks::UploadTask: after_tr
end
I am moving the call to save_thumb_version to execute before copy_to_item_storage, but since in development we only upload to s3(per Bailey) I have to test this all onstaging after redeploy cycles.
ANy thoughts on how to better test this and if there are any configuration changes needed on IA to accept a file upload (thumbnail uploading incorrectly) nested inside the the other file upload(main IMage uploading correctly).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment