We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d2b8626 commit 44389d3Copy full SHA for 44389d3
1 file changed
github3/models.py
@@ -6,6 +6,8 @@
6
"""
7
8
from .helpers import to_python, to_api
9
+import os
10
+import magic
11
from .config import settings
12
import requests
13
@@ -178,8 +180,10 @@ def downloads(self, **params):
178
180
self.name, 'downloads'), Download, **params)
179
181
182
def create_download(self, filepath, **params):
- import os
- data = {'size': os.path.getsize(filepath), 'name': filepath.split('/')[-1]}
183
+ m = magic.open(magic.MAGIC_MIME)
184
+ m.load()
185
+ mime_type = m.file(filepath)
186
+ data = {'size': os.path.getsize(filepath), 'name': filepath.split('/')[-1], 'content_type': mime_type}
187
188
dlressource = self._gh._post_resource(('repos', self.owner.login,
189
self.name, 'downloads'),
0 commit comments