-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initial changes to implement fog cloud storage library #822
Open
icarito
wants to merge
11
commits into
main
Choose a base branch
from
fog-google-cloud
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
662c128
initial changes to implement fog cloud storage library
icarito 017b94b
gemfile lock
jywarren 430808f
Update config/initializers/paperclip_string.rb
jywarren 74bb572
photo.copy_to_local_file(:original) before local ImageMagick - https:…
jywarren ada364c
initial changes to implement fog cloud storage library
icarito 9735504
Update config/initializers/paperclip_string.rb
jywarren 16d595c
,local_photo_path added to copy_to_local_file()
jywarren eeb3446
remove old test
jywarren 37da66e
save to tmp
jywarren 8bf0286
add: image.write(local_photo_path)
jywarren 3e33b58
Avoid resetting database on rebuild
icarito File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,7 +114,8 @@ def self.weekly_tallies | |
|
||
# finds the brightest row of the image and uses that as its sample row | ||
def find_brightest_row | ||
image = Magick::ImageList.new('public' + (photo.url.split('?')[0]).gsub('%20', ' ')) | ||
photo.copy_to_local_file(:original,local_photo_path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
image = Magick::ImageList.new(local_photo_path) | ||
brightest_row = 0 | ||
brightest = 0 | ||
# sum brightness for each row | ||
|
@@ -140,7 +141,8 @@ def find_brightest_row | |
def extract_data | ||
pixels = [] | ||
|
||
image = Magick::ImageList.new('public' + (photo.url.split('?')[0]).gsub('%20', ' ')) | ||
photo.copy_to_local_file(:original,local_photo_path) | ||
image = Magick::ImageList.new(local_photo_path) | ||
# saved sample_row may be greater than image height, so temporarily compensate, | ||
# but preserve sample_row in case we rotate back or something | ||
self.sample_row = image.rows - 2 if sample_row > image.rows | ||
|
@@ -278,17 +280,19 @@ def clone_calibration(clone_id) | |
|
||
# rotate clockwise | ||
def rotate | ||
image = Magick::ImageList.new('public' + (photo.url.split('?')[0]).gsub('%20', ' ')) | ||
photo.copy_to_local_file(:original,local_photo_path) | ||
image = Magick::ImageList.new(local_photo_path) | ||
image.rotate!(-90) | ||
image.write('public' + photo.url) | ||
image.write(local_photo_path) | ||
photo.reprocess! | ||
end | ||
|
||
# horizontally flips image to match reversed spectrum, toggles 'reversed' flag | ||
def reverse | ||
image = Magick::ImageList.new('public' + (photo.url.split('?')[0]).gsub('%20', ' ')) | ||
photo.copy_to_local_file(:original,local_photo_path) | ||
image = Magick::ImageList.new(local_photo_path) | ||
image.flop! | ||
image.write('public' + photo.url) | ||
image.write(local_photo_path) | ||
self.reversed = !reversed | ||
photo.reprocess! | ||
end | ||
|
@@ -629,4 +633,10 @@ def find_similar(range) | |
def spectrum_params | ||
params.require(:spectrum).permit(:title, :author, :user_id, :notes, :photo, :video_row, :data) | ||
end | ||
|
||
def local_photo_path | ||
#'public' + (photo.url.split('?')[0]).gsub('%20', ' ') | ||
"/tmp/#{self.id}" | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,6 +4,17 @@ | |||||
# Paperclip.options[:command_path] = "/usr/bin/identify" | ||||||
# Paperclip.options[:command_path] = "/usr/local/bin" | ||||||
|
||||||
Paperclip::Attachment.default_options[:storage] = :fog | ||||||
Paperclip::Attachment.default_options[:fog_directory] = ENV["GOOGLE_STORAGE_BUCKET_NAME"] || '' | ||||||
Paperclip::Attachment.default_options[:path] = ":rails_root/public/system/:attachment/:id/:style/:filename" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Paperclip::Attachment.default_options[:fog_credentials] = { | ||||||
provider: ENV["FOG_PROVIDER"] || "Local", | ||||||
local_root: "#{Rails.root}/public", | ||||||
google_project: 'public-lab' , | ||||||
google_json_key_location: ENV["GOOGLE_JSON_KEY_FILE"] || '' | ||||||
} | ||||||
Paperclip::Attachment.default_options[:fog_host] = "" | ||||||
|
||||||
# Thank you to http://bendangelo.me/?p=60 | ||||||
module Paperclip | ||||||
# converts a string into a file for paperclip to save | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do this due to fog/fog-google#535