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)
| 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}" |