diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /app/uploaders | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) | |
download | gitlab-ce-9f46488805e86b1bc341ea1620b866016c2ce5ed.tar.gz |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'app/uploaders')
-rw-r--r-- | app/uploaders/design_management/design_v432x230_uploader.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/app/uploaders/design_management/design_v432x230_uploader.rb b/app/uploaders/design_management/design_v432x230_uploader.rb new file mode 100644 index 00000000000..ba48f381bbd --- /dev/null +++ b/app/uploaders/design_management/design_v432x230_uploader.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +module DesignManagement + # This Uploader is used to generate and serve the smaller versions of + # the design files. + # + # The original (full-sized) design files are stored in Git LFS, and so + # have a different uploader, `LfsObjectUploader`. + class DesignV432x230Uploader < GitlabUploader + include CarrierWave::MiniMagick + include RecordsUploads::Concern + include ObjectStorage::Concern + prepend ObjectStorage::Extension::RecordsUploads + + # We choose not to resize `image/ico` as we assume there will be no + # benefit in generating an 432x230 sized icon. + # + # We currently cannot resize `image/tiff`. + # See https://gitlab.com/gitlab-org/gitlab/issues/207740 + # + # We currently choose not to resize `image/svg+xml` for security reasons. + # See https://gitlab.com/gitlab-org/gitlab/issues/207740#note_302766171 + MIME_TYPE_WHITELIST = %w(image/png image/jpeg image/bmp image/gif).freeze + + process resize_to_fit: [432, 230] + + # Allow CarrierWave to reject files without correct mimetypes. + def content_type_whitelist + MIME_TYPE_WHITELIST + end + + # Override `GitlabUploader` and always return false, otherwise local + # `LfsObject` files would be deleted. + # https://github.com/carrierwaveuploader/carrierwave/blob/f84672a/lib/carrierwave/uploader/cache.rb#L131-L135 + def move_to_cache + false + end + + private + + def dynamic_segment + File.join(model.class.underscore, mounted_as.to_s, model.id.to_s) + end + end +end |