mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
Upload images to S3
This commit is contained in:
parent
f2053b3ae0
commit
bb01a25614
2
Gemfile
2
Gemfile
@ -6,7 +6,7 @@ gem 'puma-heroku'
|
||||
gem 'rack-timeout'
|
||||
|
||||
# Storage
|
||||
gem 'aws-sdk', '~> 2.3'
|
||||
gem 'aws-sdk', '~> 1.5'
|
||||
|
||||
# Image processing
|
||||
gem 'paperclip'
|
||||
|
||||
16
Gemfile.lock
16
Gemfile.lock
@ -47,14 +47,11 @@ GEM
|
||||
ast (2.3.0)
|
||||
authority (3.2.2)
|
||||
activesupport (>= 3.0.0)
|
||||
aws-sdk (2.7.9)
|
||||
aws-sdk-resources (= 2.7.9)
|
||||
aws-sdk-core (2.7.9)
|
||||
aws-sigv4 (~> 1.0)
|
||||
jmespath (~> 1.0)
|
||||
aws-sdk-resources (2.7.9)
|
||||
aws-sdk-core (= 2.7.9)
|
||||
aws-sigv4 (1.0.0)
|
||||
aws-sdk (1.66.0)
|
||||
aws-sdk-v1 (= 1.66.0)
|
||||
aws-sdk-v1 (1.66.0)
|
||||
json (~> 1.4)
|
||||
nokogiri (>= 1.4.4)
|
||||
bcrypt (3.1.11)
|
||||
better_errors (2.1.1)
|
||||
coderay (>= 1.0.0)
|
||||
@ -163,7 +160,6 @@ GEM
|
||||
json (~> 1.8)
|
||||
multi_xml (>= 0.5.2)
|
||||
i18n (0.7.0)
|
||||
jmespath (1.3.1)
|
||||
json (1.8.3)
|
||||
libv8 (3.16.14.15)
|
||||
listen (3.1.5)
|
||||
@ -370,7 +366,7 @@ PLATFORMS
|
||||
|
||||
DEPENDENCIES
|
||||
authority
|
||||
aws-sdk (~> 2.3)
|
||||
aws-sdk (~> 1.5)
|
||||
bcrypt
|
||||
better_errors
|
||||
binding_of_caller
|
||||
|
||||
@ -86,12 +86,14 @@ class ContentController < ApplicationController
|
||||
content_type = content_type_from_controller(self.class)
|
||||
@content = content_type.find(params[:id])
|
||||
|
||||
raise params.inspect
|
||||
|
||||
unless @content.updatable_by? current_user
|
||||
return redirect_to :back
|
||||
end
|
||||
|
||||
if params.key? 'image_uploads'
|
||||
upload_files params['image_uploads'], content_type.name, @content.id
|
||||
end
|
||||
|
||||
if @content.update_attributes(content_params)
|
||||
successful_response(@content, t(:update_success, model_name: humanized_model_name))
|
||||
else
|
||||
@ -99,6 +101,21 @@ class ContentController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def upload_files image_uploads_hash, content_type, content_id
|
||||
image_uploads_hash.values.each do |image_data|
|
||||
related_image = ImageUpload.create(
|
||||
user: current_user,
|
||||
content_type: content_type,
|
||||
content_id: content_id,
|
||||
src: image_data,
|
||||
privacy: 'public'
|
||||
)
|
||||
raise [image_data, '|||', related_image].inspect
|
||||
end
|
||||
|
||||
raise image_uploads_hash.values.inspect
|
||||
end
|
||||
|
||||
def destroy
|
||||
content_type = content_type_from_controller(self.class)
|
||||
@content = content_type.find(params[:id])
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
<%= upload_form.label 'File upload' %>
|
||||
<%= upload_form.file_field :src, name: "image_uploads[#{uuid}]" %>
|
||||
|
||||
|
||||
<%= link_to_remove_association f do %>
|
||||
<i class="material-icons red-text" style="position: relative; top: 10px; left: -15px;">close</i>
|
||||
<% end %>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user