From 0ad1fc842df5cca1e1f6666653f6e4b049d9ab1d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 10 Oct 2013 18:05:01 +0800 Subject: [PATCH] Do not multipart-encode the uploaded file. --- script/lib/github.py | 7 +++---- script/upload.py | 11 ++++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/script/lib/github.py b/script/lib/github.py index c6ca91a..a742a20 100644 --- a/script/lib/github.py +++ b/script/lib/github.py @@ -24,15 +24,14 @@ class GitHub: headers['Authorization'] = self._authorization headers['Accept'] = 'application/vnd.github.manifold-preview' - # Data are sent in JSON format. - if 'data' in kw: - kw['data'] = json.dumps(kw['data']) - # Switch to a different domain for the releases uploading API. if self._releases_upload_api_pattern.match(path): url = '%s%s' % (GITHUB_UPLOAD_ASSET_URL, path) else: url = '%s%s' % (GITHUB_URL, path) + # Data are sent in JSON format. + if 'data' in kw: + kw['data'] = json.dumps(kw['data']) r = getattr(requests, method)(url, **kw).json() if 'message' in r: diff --git a/script/upload.py b/script/upload.py index 69227c1..026abb1 100755 --- a/script/upload.py +++ b/script/upload.py @@ -134,9 +134,10 @@ def create_release_draft(github, tag): def upload_atom_shell(github, release_id, file_path): params = {'name': os.path.basename(file_path)} headers = {'Content-Type': 'application/zip'} - files = {'file': open(file_path, 'rb')} - github.repos(ATOM_SHELL_REPO).releases(release_id).assets.post( - params=params, headers=headers, files=files, verify=False) + with open(file_path, 'rb') as f: + data = f.read() + github.repos(ATOM_SHELL_REPO).releases(release_id).assets.post( + params=params, headers=headers, data=data, verify=False) def publish_release(github, release_id): @@ -147,10 +148,6 @@ def publish_release(github, release_id): def upload_node(bucket, access_key, secret_key, version): os.chdir(DIST_DIR) - # TODO(zcbenz): Remove me when Atom starts to use Releases API. - s3put(bucket, access_key, secret_key, DIST_DIR, - 'atom-shell/{0}'.format(ATOM_SHELL_VRESION), [DIST_NAME]) - s3put(bucket, access_key, secret_key, DIST_DIR, 'atom-shell/dist/{0}'.format(version), glob.glob('node-*.tar.gz')) -- 2.7.4