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

266
Visualizações
Calculating the ETag for a local file in Node.js while uploading to AWS S3

I'm currently trying to implement a system that verifies the integrity of files I upload to S3. Through the AWS SDK for JavaScript, I am able to retrieve the ETag of the remote object, however, the MD5 hash for my local object doesn't match the ETag. I am currently using crypto for generating it, as follows:

var hash = crypto.createHash('md5');
stream = fs.createReadStream(localfile);

stream.on('data', function (data) {
  hash.update(data, 'utf8')
})

stream.on('end', function () {
  md5 = hash.digest('hex');

  < rest of the code >
});

According to all the results I've found while looking for answers, the ETags for S3 objects should be simple MD5 hashes: e.g. the AWS documentation (emphasis mine):

To ensure that data is not corrupted traversing the network, use the Content-MD5 header. When you use this header, Amazon S3 checks the object against the provided MD5 value and, if they do not match, returns an error. Additionally, you can calculate the MD5 while putting an object to Amazon S3 and compare the returned ETag to the calculated MD5 value.

However, my local hash doesn't match the remote ETag. Am I missing anything here?

Thanks for your time!

Clarification: I'm only uploading small plain text files, and I'm not dealing with multi-part uploads. I've seen that a lot of questions around the web are in regards to multi-part uploads, but this is just for simple uploads. Thanks!

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Problem Exists Between Keyboard And Chair. The issue was with the actual file uploads and not with the md5 sum. See the comment section in the original question.

over 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