fix: Remove uso de ACL nos uploads para S3#111
Merged
Conversation
Buckets S3 modernos frequentemente têm 'Object Ownership' configurado como 'Bucket owner enforced', o que desabilita ACLs completamente. Isso causava erros 'AccessControlListNotSupported' ao tentar fazer upload de arquivos. Esta mudança remove todos os parâmetros ACL das operações de upload: - upload_content() - upload_file() - upload_file_multipart() O acesso público agora deve ser controlado via políticas de bucket ao invés de ACLs em nível de objeto, seguindo as melhores práticas da AWS. Corrige o erro AccessControlListNotSupported ao fazer upload para S3.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problema
Ao tentar fazer upload de arquivos para S3, ocorria o erro:
Isso acontece porque buckets S3 modernos frequentemente têm a configuração 'Object Ownership' definida como 'Bucket owner enforced', o que desabilita ACLs completamente.
Solução
Esta PR remove todos os parâmetros ACL das operações de upload no módulo
storage/digital_ocean_spaces.py:upload_content()- RemovidoExtraArgs={"ACL": permission}upload_file()- RemovidoExtraArgs={"ACL": permission}upload_file_multipart()- Removido parâmetroACL=permissionComo controlar acesso público agora?
O acesso público deve ser controlado através de políticas de bucket ao invés de ACLs em nível de objeto, seguindo as melhores práticas da AWS:
{ "Version": "2012-10-17", "Statement": [{ "Sid": "PublicRead", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::nome-do-bucket/*" }] }Testes
tests/digital_ocean_spaces.pyNota
Este não era um problema de permissão IAM faltante, mas sim uma incompatibilidade entre o código (que tentava definir ACLs) e a configuração do bucket (que desabilita ACLs).