-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
20 additions
and
58 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,3 @@ | ||
# frozen_string_literal: true | ||
class UploadingController < ApplicationController | ||
protected | ||
|
||
def set_s3_url | ||
return if params[:type] == "existing" | ||
|
||
presign_conf = {} | ||
if !Rails.env.production? && ENV.key?('MINIO_ENDPOINT') && ENV.key?('MINIO_ENDPOINT_EXTERNAL') | ||
# for minio and Docker compatibility, replace the guest-compatible "minio" host with the host-compatible "localhost" path | ||
standard_endpoint = ENV.fetch('MINIO_ENDPOINT', nil) | ||
replacement_endpoint = ENV.fetch('MINIO_ENDPOINT_EXTERNAL', nil) | ||
bucket_url = S3_BUCKET.url | ||
unless bucket_url.include?(standard_endpoint) | ||
raise RuntimeError.new("couldn't find minio endpoint in direct post URL: #{standard_endpoint} in #{bucket_url}") | ||
end | ||
presign_conf[:url] = bucket_url.sub(standard_endpoint, replacement_endpoint) | ||
end | ||
|
||
@s3_direct_post = S3_BUCKET.presigned_post( | ||
key: "users/#{current_user.id}/icons/${filename}", | ||
success_action_status: '201', | ||
acl: 'public-read', | ||
content_type_starts_with: 'image/', | ||
cache_control: 'public, max-age=31536000', | ||
**presign_conf, | ||
) | ||
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
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