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

165
Visualizações
Specify tags using the x-amz-tagging request header

I have a Node program for file uploading to aws s3, I need to specify the x-amz-tagging with the request header. I tried something but it doesn't work!

function buildRequestHeader() {
  return {
    'Content-Length': fileBuffer.size,
    'Content-Type': mimeType,
    'x-amz-acl': 'public-read',
    'x-amz-tagging' :{"tag1":'abcd',"tag2":'efgh'}
  }
}

I have seen something from aws docs,

PUT object-key?tagging HTTP/1.1
Host: examplebucket.s3.amazonaws.com
Content-Length: length
Content-MD5: pUNXr/BjKK5G2UKExample==
x-amz-date: 20160923T001956Z
Authorization: authorization string
<Tagging>
   <TagSet>
      <Tag>
         <Key>tag1</Key>
         <Value>val1</Value>
      </Tag>
      <Tag>
         <Key>tag2</Key>
         <Value>val2</Value>
      </Tag>
   </TagSet>
</Tagging>

Could you please explain how it works?

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

The code snippets you show are from two different methods of tagging, the first during object creation, the second is adding tags to an existing object.

The x-amz-tagging header is what you would use during object creation, but it uses a different syntax than in your example. Try this instead:

function buildRequestHeader() {
  return {
    'Content-Length': fileBuffer.size,
    'Content-Type': mimeType,
    'x-amz-acl': 'public-read',
    'x-amz-tagging': 'tag1=abcd&tag2=efgh'
  }
}
about 4 years ago · Santiago Trujillo Relatório

0

const fs= require('fs');
const AWS = require('aws-sdk');
const s3 = new AWS.S3({'accesskey':'accesskeyvalue','region':'your s3 region'})

s3.upload(
  {
    Bucket: bucket_name,
    Key: key,
    Tagging: 'tag1=abcd&tag2=efgh',
    Body: fs.createReadStream('./filename.filetype'),
  }

this method is also working!!

about 4 years ago · Santiago Trujillo 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