Allow unsetting x-amz-acl S3 Permission headers (#20510)
Some "S3 Compatible" storage providers (Cloudflare R2 is one such example) don't support setting ACLs on individual uploads with the `x-amz-acl` header, and instead just have a visibility for the whole bucket. To support uploads to such providers without getting unsupported errors back, lets use a black `S3_PERMISSION` env var to indicate that these headers shouldn't be sent. This is tested as working with Cloudflare R2.
This commit is contained in:
		
							parent
							
								
									29cddeffaf
								
							
						
					
					
						commit
						df557906fb
					
				
					 1 changed files with 6 additions and 0 deletions
				
			
		|  | @ -68,6 +68,12 @@ if ENV['S3_ENABLED'] == 'true' | ||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
|    |    | ||||||
|  |   if ENV['S3_PERMISSION'] == '' | ||||||
|  |     Paperclip::Attachment.default_options.merge!( | ||||||
|  |       s3_permissions: ->(*) { nil } | ||||||
|  |     ) | ||||||
|  |   end | ||||||
|  | 
 | ||||||
|   if ENV.has_key?('S3_ENDPOINT') |   if ENV.has_key?('S3_ENDPOINT') | ||||||
|     Paperclip::Attachment.default_options[:s3_options].merge!( |     Paperclip::Attachment.default_options[:s3_options].merge!( | ||||||
|       endpoint: ENV['S3_ENDPOINT'], |       endpoint: ENV['S3_ENDPOINT'], | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue