Skip to content

Commit 2484c07

Browse files
committed
I'm still fiddling with Downloads.
I'm going to have to sniff the traffic to find out the difference between how curl sends everything and how this is sending it.
1 parent 22db4b9 commit 2484c07

2 files changed

Lines changed: 16 additions & 39 deletions

File tree

github3/repo.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
77
"""
88

9-
from base64 import b64decode
9+
from base64 import b64decode, b64encode
1010
from time import time
1111
from json import dumps
1212
import requests
1313
from .issue import Issue, Label, Milestone, issue_params
1414
from .git import Blob, Commit, Reference, Tag
1515
from .models import GitHubCore, BaseComment, BaseCommit
1616
from .pulls import PullRequest
17-
from .structs import OrderedDict
1817
from .user import User, Key
1918

2019

@@ -246,24 +245,27 @@ def create_download(self, name, path, description='',
246245
json = self._post(url, data)
247246

248247
if json:
249-
form = [('key', json.get('path')), ('acl', json.get('acl')),
248+
form_vals = [('key', json.get('path')),
249+
('acl', json.get('acl')),
250250
('success_action_status', '201'),
251251
('Filename', json.get('name')),
252-
('Expires', int(time()) + 100),
253252
('AWSAccessKeyId', json.get('accesskeyid')),
254253
('Policy', json.get('policy')),
255254
('Signature', json.get('signature')),
256255
('Content-Type', json.get('mime_type')),
257-
('file', {json.get('name'): open(path, 'rb').read()})]
258-
#files = {json.get('name'): open(path, 'rb')}
259-
#resp = requests.post(json.get('s3_url'), # headers=headers,
260-
# data=form, files=files)
261-
#headers = {'Authorization': 'AWS {0}:{1}'.format(
262-
# json.get('accesskeyid'), json.get('signature'))}
263-
resp = requests.post(json.get('s3_url'), data=OrderedDict(form),
264-
headers=headers)
265-
#resp = requests.post('http://httpbin.org/post', headers=headers,
266-
# files=form)
256+
('file', b64encode(open(path, 'rb').read()))]
257+
# form = """--github
258+
#Content-Disposition: form-data; name="{key}"
259+
#
260+
#{value}
261+
#"""
262+
# data = ''
263+
# for (k, v) in form_vals:
264+
# data = ''.join([data, form.format(key=k, value=v)])
265+
# data = ''.join([data, '--github--'])
266+
# headers = {'Content-Type': 'multipart/form-data; boundary=github',
267+
# 'Content-Length': str(len(data))}
268+
resp = requests.post(json.get('s3_url'), data=form_vals)
267269
print(resp)
268270
print(resp.content)
269271

github3/structs.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)