MCPcopy
hub / github.com/commaai/openpilot / upload_file

Method upload_file

tools/lib/github_utils.py:35–49  ·  view source on GitHub ↗
(self, bucket, path, file_name)

Source from the content-addressed store, hash-verified

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)

Callers 4

upload_filesMethod · 0.95
upload_routeFunction · 0.45
comment_replay_reportFunction · 0.45
model_replay.pyFile · 0.45

Calls 3

get_file_shaMethod · 0.95
api_callMethod · 0.95
readMethod · 0.45

Tested by

no test coverage detected