def post_download(project, filename, name=None, description=''):
 if (name is None):
  name = os.path.basename(filename)
 with open(filename, 'rb') as f:
  filedata = f.read()
 url = 'https://api.github.com/repos/{project}/downloads'.format(project=project)
 payload = json.dumps(dict(name=name, size=len(filedata), description=description))
 response = requests.post(url, data=payload, headers=make_auth_header())
 response.raise_for_status()
 reply = json.loads(response.content)
 s3_url = reply['s3_url']
 fields = dict(key=reply['path'], acl=reply['acl'], success_action_status=201, Filename=reply['name'], AWSAccessKeyId=reply['accesskeyid'], Policy=reply['policy'], Signature=reply['signature'], file=(reply['name'], filedata))
 fields['Content-Type'] = reply['mime_type']
 (data, content_type) = encode_multipart_formdata(fields)
 s3r = requests.post(s3_url, data=data, headers={'Content-Type': content_type})
 return s3r

def post_download ( project , filename , name = None , description = '' ) : if ( name is None ) : name = os . path . basename ( filename ) with open ( filename , 'rb' ) as f : filedata = f . read ( ) url = 'https://api.github.com/repos/{project}/downloads' . format ( project = project ) payload = json . dumps ( dict ( name = name , size = len ( filedata ) , description = description ) ) response = requests . post ( url , data = payload , headers = make_auth_header ( ) ) response . raise_for_status ( ) reply = json . loads ( response . content ) s3_url = reply [ 's3_url' ] fields = dict ( key = reply [ 'path' ] , acl = reply [ 'acl' ] , success_action_status = 201 , Filename = reply [ 'name' ] , AWSAccessKeyId = reply [ 'accesskeyid' ] , Policy = reply [ 'policy' ] , Signature = reply [ 'signature' ] , file = ( reply [ 'name' ] , filedata ) ) fields [ 'Content-Type' ] = reply [ 'mime_type' ] ( data , content_type ) = encode_multipart_formdata ( fields ) s3r = requests . post ( s3_url , data = data , headers = { 'Content-Type' : content_type } ) return s3r
upload a file to the github downloads area .