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

138
Visualizações
How to set a custom header using @aws-sdk/client-s3?

Cloudflare's R2 has an extension that prevents a NoSuchBucket error, by creating the bucket if it does not exist. To enable it, you're supposed to add a cf-create-bucket-if-missing: true header on the PutObject request. Can this header be set if we're using the @aws-sdk/client-s3 npm package? If so, how?

If the answer is no, is there an alternative workaround that you would recommend?

If it helps, I'm creating a backend nestjs API, and would like to include this header in outgoing requests.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The AWS SDK v2 allows you to modify requests via Middleware.

Here’s an example of adding a custom header using middleware:

const client = new S3({ region: "us-east-1" });

client.middlewareStack.add(
  (next, context) => (args) => {
    args.request.headers["cf-create-bucket-if-missing"] = "true";
    return next(args);
  },
  {
    step: "serialize",
  }
);

const params = {}; // TODO: fill in usual PutObject params

await client.PutObject(params);

There's a good article that dives into the middleware stack here.

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