@@ -31,11 +31,15 @@ def download_fn(downloadDir=None):
31
31
tempStorage = io .BytesIO ()
32
32
for block in r .iter_content (1024 ):
33
33
tempStorage .write (block )
34
- if downloadDir is None : return tempStorage .getvalue ()
35
- with open (downloadDir , 'wb' ) as f : f .write (tempStorage .getvalue ())
34
+ if downloadDir is None :
35
+ return tempStorage .getvalue ()
36
+ with open (downloadDir , 'wb' ) as f :
37
+ f .write (tempStorage .getvalue ())
38
+ tempStorage .seek (0 )
36
39
return ReturnValue ({'BaseResponse' : {
37
40
'ErrMsg' : 'Successfully downloaded' ,
38
- 'Ret' : 0 , }})
41
+ 'Ret' : 0 , },
42
+ 'PostFix' : utils .get_image_postfix (tempStorage .read (20 )), })
39
43
return download_fn
40
44
41
45
def produce_msg (core , msgList ):
@@ -101,8 +105,10 @@ def download_video(videoDir=None):
101
105
tempStorage = io .BytesIO ()
102
106
for block in r .iter_content (1024 ):
103
107
tempStorage .write (block )
104
- if videoDir is None : return tempStorage .getvalue ()
105
- with open (videoDir , 'wb' ) as f : f .write (tempStorage .getvalue ())
108
+ if videoDir is None :
109
+ return tempStorage .getvalue ()
110
+ with open (videoDir , 'wb' ) as f :
111
+ f .write (tempStorage .getvalue ())
106
112
return ReturnValue ({'BaseResponse' : {
107
113
'ErrMsg' : 'Successfully downloaded' ,
108
114
'Ret' : 0 , }})
@@ -128,8 +134,10 @@ def download_atta(attaDir=None):
128
134
tempStorage = io .BytesIO ()
129
135
for block in r .iter_content (1024 ):
130
136
tempStorage .write (block )
131
- if attaDir is None : return tempStorage .getvalue ()
132
- with open (attaDir , 'wb' ) as f : f .write (tempStorage .getvalue ())
137
+ if attaDir is None :
138
+ return tempStorage .getvalue ()
139
+ with open (attaDir , 'wb' ) as f :
140
+ f .write (tempStorage .getvalue ())
133
141
return ReturnValue ({'BaseResponse' : {
134
142
'ErrMsg' : 'Successfully downloaded' ,
135
143
'Ret' : 0 , }})
@@ -255,7 +263,8 @@ def upload_file(self, fileDir, isPicture=False, isVideo=False,
255
263
'Ret' : - 1002 , }})
256
264
fileSize = os .path .getsize (fileDir )
257
265
fileSymbol = 'pic' if isPicture else 'video' if isVideo else 'doc'
258
- with open (fileDir , 'rb' ) as f : fileMd5 = hashlib .md5 (f .read ()).hexdigest ()
266
+ with open (fileDir , 'rb' ) as f :
267
+ fileMd5 = hashlib .md5 (f .read ()).hexdigest ()
259
268
file_ = open (fileDir , 'rb' )
260
269
chunks = int ((fileSize - 1 ) / 524288 ) + 1
261
270
clientMediaId = int (time .time () * 1e4 )
0 commit comments