|
6 | 6 | """ |
7 | 7 |
|
8 | 8 | from .helpers import to_python, to_api |
9 | | - |
| 9 | +from .config import settings |
| 10 | +import requests |
10 | 11 |
|
11 | 12 | class BaseResource(object): |
12 | 13 | """A BaseResource object.""" |
@@ -181,29 +182,25 @@ def create_download(self, filepath, **params): |
181 | 182 | data = {'size': os.path.getsize(filepath), 'name': filepath.split('/')[-1]} |
182 | 183 |
|
183 | 184 | dlressource = self._gh._post_resource(('repos', self.owner.login, |
184 | | - self.name, 'downloads'), DownloadRessource, data=self._gh._resource_serialize(data), **params) |
185 | | - |
186 | | - curl_command = list(); |
187 | | - curl_command.append('curl') |
188 | | - curl_command.append('-s') |
189 | | - curl_command.append('-F key='+dlressource.path) |
190 | | - curl_command.append('-F acl='+dlressource.acl) |
191 | | - curl_command.append('-F success_action_status=201') |
192 | | - curl_command.append('-F Filename='+dlressource.name) |
193 | | - curl_command.append('-F AWSAccessKeyId='+dlressource.accesskeyid) |
194 | | - curl_command.append('-F Policy='+dlressource.policy) |
195 | | - curl_command.append('-F Signature='+dlressource.signature) |
196 | | - curl_command.append('-F Content-Type='+dlressource.mime_type) |
197 | | - curl_command.append('-F file=@'+filepath+'') |
198 | | - curl_command.append('https://github.s3.amazonaws.com/') |
199 | | - import subprocess |
200 | | - p = subprocess.Popen(curl_command, |
201 | | - env=os.environ, |
202 | | - stdin=subprocess.PIPE, |
203 | | - stdout=subprocess.PIPE, |
204 | | - stderr=subprocess.PIPE, |
205 | | - ) |
206 | | - out, err = p.communicate() |
| 185 | + self.name, 'downloads'), |
| 186 | + DownloadRessource, |
| 187 | + data=self._gh._resource_serialize(data), |
| 188 | + **params) |
| 189 | + form = {} |
| 190 | + form['key'] = dlressource.path |
| 191 | + form['acl'] = dlressource.acl |
| 192 | + form['success_action_status'] = '201' |
| 193 | + form['Filename'] = dlressource.name |
| 194 | + form['AWSAccessKeyId'] = dlressource.accesskeyid |
| 195 | + form['Policy'] = dlressource.policy |
| 196 | + form['Signature'] = dlressource.signature |
| 197 | + form['Content-Type'] = dlressource.mime_type |
| 198 | + |
| 199 | + myfile = open(filepath) |
| 200 | + |
| 201 | + files = {'file' : myfile} |
| 202 | + |
| 203 | + r = requests.post(settings.github_upload_file_url, data=form, files=files, **params) |
207 | 204 | return dlressource; |
208 | 205 |
|
209 | 206 |
|
|
0 commit comments