Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
AWS S3 createPresignedPost URL can upload file of any size despite limiting it

I'm creating a pre-signed URL so the user in the front end can upload a file (max 10MB) this is how I create it

  const s3Params = {
        Bucket: S3_BUCKET,
        Expires: 30,
        Fields: {
            key: key,
        },
        Conditions: [
            ["eq", "$acl", "public-read"],
            ["eq", "$x-amz-meta-filename", fileName],
            ["content-length-range", 1, 10000000], //10MB
            ["eq", "$x-amz-meta-userid", userid],
        ],
    };

    console.log(s3Params);

    s3.createPresignedPost(s3Params, (err, data) => {
        if (err) {
            console.log(err);
            return cb({success: false, error: err});
        }

        data.fields["x-amz-meta-filename"] = fileName;
        data.fields["x-amz-meta-userid"] = userid;

        const returnData = {
            signedRequest: data,
            url: `https://${S3_BUCKET}.s3.amazonaws.com/${key}`,
        };
        return cb({success: true, data: {returnData}});
    });

in the Conditions set the max file size (content-length-range) to be 10MB but I was still able to upload a 25 MB file using the generated Pre signed URL. I was thinking it might have something to do with the bucket policy but I'm not sure.

Here is my Bucket Policy

    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": "arn:aws:s3:::blah.blah/*"
        }
    ]
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I think your conditions are simply ignored because the bucket allows for anonymous writes (very terrible practice!). From docs:

If you don't provide elements required for authenticated requests, such as the policy element, the request is assumed to be anonymous and will succeed only if you have configured the bucket for public read and write.

When you are using pre-signed urls, you shouldn't make your bucket public.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda