diff --git a/swh/model/from_disk.py b/swh/model/from_disk.py
index 4767c39890e71721519b25257a31413aa680cac8..a9fc2d3be52ef0869c1eea2a10497bde02d775dd 100644
--- a/swh/model/from_disk.py
+++ b/swh/model/from_disk.py
@@ -124,7 +124,10 @@ class Content(MerkleLeaf):
             h = MultiHash(length=length)
             chunks = []
             with open(path, 'rb') as fobj:
-                for chunk in fobj:
+                while True:
+                    chunk = fobj.read(HASH_BLOCK_SIZE)
+                    if not chunk:
+                        break
                     h.update(chunk)
                     chunks.append(chunk)
 
diff --git a/swh/model/hashutil.py b/swh/model/hashutil.py
index d8249bc70b5d5b81286a7d945a3fb07d23ea969c..24c2f6961f8039572632367b84363c9b4478d367 100644
--- a/swh/model/hashutil.py
+++ b/swh/model/hashutil.py
@@ -117,9 +117,12 @@ class MultiHash:
         ret.track_length = track_length
 
     @classmethod
-    def from_file(cls, file, hash_names=DEFAULT_ALGORITHMS, length=None):
+    def from_file(cls, fobj, hash_names=DEFAULT_ALGORITHMS, length=None):
         ret = cls(length=length, hash_names=hash_names)
-        for chunk in file:
+        while True:
+            chunk = fobj.read(HASH_BLOCK_SIZE)
+            if not chunk:
+                break
             ret.update(chunk)
         return ret