Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

260
Views
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!

about 4 years ago · Santiago Trujillo
1 answers
Answer question

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.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!