MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / post_download

Function post_download

tools/gh_api.py:264–293  ·  view source on GitHub ↗

Upload a file to the GitHub downloads area

(project, filename, name=None, description="")

Source from the content-addressed store, hash-verified

262
263
264def post_download(project, filename, name=None, description=""):
265 """Upload a file to the GitHub downloads area"""
266 if name is None:
267 name = os.path.basename(filename)
268 with open(filename, 'rb') as f:
269 filedata = f.read()
270
271 url = f"https://api.github.com/repos/{project}/downloads"
272
273 payload = json.dumps(dict(name=name, size=len(filedata),
274 description=description))
275 response = requests.post(url, data=payload, headers=make_auth_header())
276 response.raise_for_status()
277 reply = json.loads(response.content)
278 s3_url = reply['s3_url']
279
280 fields = dict(
281 key=reply['path'],
282 acl=reply['acl'],
283 success_action_status=201,
284 Filename=reply['name'],
285 AWSAccessKeyId=reply['accesskeyid'],
286 Policy=reply['policy'],
287 Signature=reply['signature'],
288 file=(reply['name'], filedata),
289 )
290 fields['Content-Type'] = reply['mime_type']
291 data, content_type = encode_multipart_formdata(fields)
292 s3r = requests.post(s3_url, data=data, headers={'Content-Type': content_type})
293 return s3r

Callers

nothing calls this directly

Calls 2

make_auth_headerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…