(self, bucket, path, file_name)
| 33 | return r |
| 34 | |
| 35 | def upload_file(self, bucket, path, file_name): |
| 36 | with open(path, "rb") as f: |
| 37 | encoded = base64.b64encode(f.read()).decode() |
| 38 | |
| 39 | # check if file already exists |
| 40 | sha = self.get_file_sha(bucket, file_name) |
| 41 | sha = f'"sha":"{sha}",' if sha else '' |
| 42 | |
| 43 | data = f'{{"message":"uploading {file_name}", \ |
| 44 | "branch":"{bucket}", \ |
| 45 | "committer":{{"name":"Vehicle Researcher", "email": "user@comma.ai"}}, \ |
| 46 | {sha} \ |
| 47 | "content":"{encoded}"}}' |
| 48 | github_path = f"contents/{file_name}" |
| 49 | self.api_call(github_path, data=data, method=HTTPMethod.PUT, data_call=True) |
| 50 | |
| 51 | def upload_files(self, bucket, files): |
| 52 | self.create_bucket(bucket) |
no test coverage detected