# Verify Hash of file

**URL:** <https://forum.storj.io/t/verify-hash-of-file/16948>\
**Category:** Developer Discussions\
**Created:** [January 27, 2022, 6:31am UTC](https://forum.storj.io/t/verify-hash-of-file/16948 "2022-01-27T06:31:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![awcchungster](https://storj.bcdn.literatehosting.com/letter_avatar/awcchungster/32/6_449c533f586939b6e5f246632a46421f.png) [@awcchungster](https://forum.storj.io/u/awcchungster)\
**Post date:** [January 27, 2022, 6:31am UTC](https://forum.storj.io/t/verify-hash-of-file/16948/1 "2022-01-27T06:31:25Z")

</div>

Is there a way to get the hash of the file either through Storj or S3 gateway?

My use case is I want to very if my local file has already been uploaded To Storj. I also want to check if my local file is identical to Storj.

Thanks!

---

<div class="post-metadata">

**Author:** ![mya](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/mya/32/11658_2.png) [@mya](https://forum.storj.io/u/mya)\
**Post date:** [January 27, 2022, 2:09pm UTC](https://forum.storj.io/t/verify-hash-of-file/16948/2 "2022-01-27T14:09:09Z")

</div>

I don’t believe this is functionality native to Storj or S3 implementations in general. I’ve seen folks implement this by storing files using their hash and then having another object reference or link to the hashed version. This way, you can quickly check if a file with the same hash exists and that the current file reference points to the current hash.

---

<div class="post-metadata">

**Author:** ![BrightSilence](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/brightsilence/32/6048_2.png) [@BrightSilence](https://forum.storj.io/u/BrightSilence)\
**Post date:** [January 27, 2022, 5:18pm UTC](https://forum.storj.io/t/verify-hash-of-file/16948/3 "2022-01-27T17:18:39Z")

</div>

That’s a clever trick to add it on. Should work in most scenarios unless the intention was to check the remote file integrity. If that was the intention, I can add that it’s basically not possible for the remote data to change. If a node would change data in their piece, the erasure coding will no longer work for that piece and when recombining the data into the original file, other pieces will simply be used to recombine the original file. In the extreme case that too many pieces have been altered to reconstruct the file, you would get an error. You would never get data that doesn’t match the original file.

However, to my knowledge that extreme case has never happened, because Storj ensures data is repaired long before that could ever occur.

---

<div class="post-metadata">

**Author:** ![awcchungster](https://storj.bcdn.literatehosting.com/letter_avatar/awcchungster/32/6_449c533f586939b6e5f246632a46421f.png) [@awcchungster](https://forum.storj.io/u/awcchungster)\
**Post date:** [January 27, 2022, 5:36pm UTC](https://forum.storj.io/t/verify-hash-of-file/16948/4 "2022-01-27T17:36:50Z")

</div>

Does Storj S3 support tags?

> **[Common Response Headers - Amazon Simple Storage Service](https://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonResponseHeaders.html)**
>
> The following table describes response headers that are common to most AWS S3 responses.

or S3 md5 verification?

> **[Check the integrity of an object uploaded to Amazon S3](https://aws.amazon.com/premiumsupport/knowledge-center/data-integrity-s3/)**

Could I check upload size and check it’s the same size as the local file size at a minimum?

---

<div class="post-metadata">

**Author:** ![mya](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/mya/32/11658_2.png) [@mya](https://forum.storj.io/u/mya)\
**Post date:** [January 27, 2022, 5:52pm UTC](https://forum.storj.io/t/verify-hash-of-file/16948/5 "2022-01-27T17:52:07Z")

</div>

Storj does support attaching custom metadata to objects. Here’s a post that shows how duplicati adds information such as `LastAccess` and `LastModification`:

- [Integrating Decentralized Cloud Storage with Duplicati](https://www.storj.io/blog/integrating-decentralized-cloud-storage-with-duplicati)

Similarly, you could add an `md5sum` or `sha256sum` value to the custom metadata to indicate what the objects signature is/should be.

---

<div class="post-metadata">

**Author:** ![Toyoo](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/toyoo/32/1126_2.png) [@Toyoo](https://forum.storj.io/u/Toyoo)\
**Post date:** [January 27, 2022, 6:26pm UTC](https://forum.storj.io/t/verify-hash-of-file/16948/6 "2022-01-27T18:26:14Z")

</div>

Some cloud storage systems do have this as a feature, see e.g. the “Hash” column in this table: [Overview of cloud storage systems](https://rclone.org/overview/)

---

<div class="post-metadata">

**Author:** ![wthorp](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/wthorp/32/1139_2.png) [@wthorp](https://forum.storj.io/u/wthorp)\
**Post date:** [February 4, 2022, 2:25pm UTC](https://forum.storj.io/t/verify-hash-of-file/16948/7 "2022-02-04T14:25:44Z")

</div>

We definitely support using ETags in Gateway-MT using HeadObject (HTTP HEAD) requests, similar to S3. Behind the scenes this updates object Metadata. In the native Uplink API, you can call `StatObject` which returns `SystemMetadata` including a `Created` timestamp. If you’re looking for simple remote change detection, this should work. `StatObject` also optionally also returns `CustomMetadata` which can be tailored to specific use cases. You can get a sense of this using the uplink CLI tool and the command `uplink ls --access $ACCESS sj://bucket/myfile --expanded`
