|
...
|
...
|
@@ -24,7 +24,16 @@ module Kanjai |
|
24
|
24
|
def update
|
|
25
|
25
|
@file = Kanjai::Image.find(params[:id])
|
|
26
|
26
|
if @file.update(permitted_params[:image])
|
|
27
|
|
- @file.resize! if params[:image] && params[:image][:image_link].present?
|
|
|
27
|
+ if params[:image] && params[:image][:image_link].present?
|
|
|
28
|
+ obj = S3_BUCKET.object(params[:image][:image_link].split('/')[3..-1].join('/'))
|
|
|
29
|
+ if File.extname(params[:image][:image_link]) == '.svg'
|
|
|
30
|
+ metadata = obj.metadata
|
|
|
31
|
+ content_type = "image/svg+xml"
|
|
|
32
|
+ obj.copy_to(key: params[:image][:image_link].split('/')[3..-1].join('/'), bucket: ENV['S3_BUCKET'], metadata: metadata, content_type: content_type, metadata_directive: 'REPLACE', acl: 'public-read')
|
|
|
33
|
+ end
|
|
|
34
|
+ @file.resize!
|
|
|
35
|
+
|
|
|
36
|
+ end
|
|
28
|
37
|
render json: {status: 'ok', id: @file.id, link: @file.preview_link}
|
|
29
|
38
|
else
|
|
30
|
39
|
render json: {status: 'error', message: @file.errors.full_message}
|
|
...
|
...
|
@@ -36,7 +45,11 @@ module Kanjai |
|
36
|
45
|
params[:gallery_image].each do |key, data|
|
|
37
|
46
|
|
|
38
|
47
|
obj = S3_BUCKET.object(data['file'].split('/')[3..-1].join('/'))
|
|
39
|
|
-
|
|
|
48
|
+ if File.extname(data['file']) == '.svg'
|
|
|
49
|
+ metadata = obj.metadata
|
|
|
50
|
+ content_type = "image/svg+xml"
|
|
|
51
|
+ obj.copy_to(key: data['file'].split('/')[3..-1].join('/'), bucket: ENV['S3_BUCKET'], metadata: metadata, content_type: content_type, metadata_directive: 'REPLACE', acl: 'public-read')
|
|
|
52
|
+ end
|
|
40
|
53
|
|
|
41
|
54
|
image = Image.create({
|
|
42
|
55
|
title: data['name'],
|
...
|
...
|
|