Browse Source

[aws] HEAD on get_key to avoid downloading all the key

Downloading should be handled in the KeyFile#read()
Romain Rigaux 4 years ago
parent
commit
a30692ae1f
1 changed files with 2 additions and 4 deletions
  1. 2 4
      desktop/libs/aws/src/aws/s3/s3connection.py

+ 2 - 4
desktop/libs/aws/src/aws/s3/s3connection.py

@@ -106,14 +106,12 @@ class UrlBucket(Bucket):
 
 
   def get_key(self, key_name, headers=None, version_id=None, response_headers=None, validate=True):
-    # Note: in current FS API, this fetches the full file... hence why it can be very slow.
-    # To check if we should give a length in read() to mitigate and just get metadata: HEAD ?
     LOG.debug('key name: %s' % key_name)
     kwargs = {'bucket': self.name, 'key': key_name}
 
-    tmp_url = self.connection.generate_url(3000, 'GET', **kwargs)
+    tmp_url = self.connection.generate_url(3000, 'HEAD', **kwargs)
 
-    response = requests.get(tmp_url)
+    response = requests.head(tmp_url)
     LOG.debug(response)
     LOG.debug(response.content)