MCPcopy Create free account
hub / github.com/aws/aws-cli / file_exists

Method file_exists

awscli/customizations/s3uploader.py:166–181  ·  view source on GitHub ↗

Check if the file we are trying to upload already exists in S3 :param remote_path: :return: True, if file exists. False, otherwise

(self, remote_path)

Source from the content-addressed store, hash-verified

164 return self.upload(file_name, remote_path)
165
166 def file_exists(self, remote_path):
167 """
168 Check if the file we are trying to upload already exists in S3
169
170 :param remote_path:
171 :return: True, if file exists. False, otherwise
172 """
173
174 try:
175 # Find the object that matches this ETag
176 self.s3.head_object(Bucket=self.bucket_name, Key=remote_path)
177 return True
178 except botocore.exceptions.ClientError:
179 # Either File does not exist or we are unable to get
180 # this information.
181 return False
182
183 def make_url(self, obj_path):
184 return f"s3://{self.bucket_name}/{obj_path}"

Callers 2

test_file_existsMethod · 0.95
uploadMethod · 0.95

Calls 1

head_objectMethod · 0.45

Tested by 1

test_file_existsMethod · 0.76