Commit 75b9fa28f7af937ad1fcb19337137da91f8c2a91

Authored by Karpikau Andrei
1 parent 69da4417

add mime type to file upload

... ... @@ -1544,11 +1544,6 @@ var initAjaxFileUpload = function(selector){
1544 1544
1545 1545 $('.' + class_name).find('.progress-bar').css('width', '0%');
1546 1546 },
1547   - send: function(e, data){
1548   - //if(data.files[0].type != ''){
1549   - data.formData['content-type'] = data.files[0].type;
1550   - //}
1551   - },
1552 1547 done: function (e, data) {
1553 1548 submitButton.prop('disabled', false);
1554 1549
... ...
... ... @@ -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'],
... ...
1 1 module Kanjai
2   - VERSION = "0.0.227"
  2 + VERSION = "0.0.228"
3 3 end
... ...