-
Notifications
You must be signed in to change notification settings - Fork 130
Add globally available method to allow for uploading binary object #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit references maxtepkeev#186 Signed-off-by: hjpotter92 <hjpotter92+github@gmail.com>
Changes Unknown when pulling 8efbee2 on hjpotter92:issues/186 into ** on maxtepkeev:master**. |
1 similar comment
Changes Unknown when pulling 8efbee2 on hjpotter92:issues/186 into ** on maxtepkeev:master**. |
I don't see why we need additional method for this, just implement this logic inside existing |
* The method first checks if the parameter is of type `file`, otherwise proceeds as before. * Define `url` and `headers` before any processing is done. Signed-off-by: hjpotter92 <hjpotter92+github@gmail.com>
Changes Unknown when pulling a3df849 on hjpotter92:issues/186 into ** on maxtepkeev:master**. |
Also allow for `StringIO` type variables Signed-off-by: hjpotter92 <hjpotter92+github@gmail.com>
Changes Unknown when pulling 1a5b9f1 on hjpotter92:issues/186 into ** on maxtepkeev:master**. |
@maxtepkeev For tests, I'd have to create a StringIO instance. I am not sure whether that is a good idea though! |
@hjpotter92 Sorry for the delay with reply. Can you please elaborate why do you think it may be not a good idea ? |
It'd require different test cases (or try-catch implementation) for different python versions; which I consider to be a hacky method. |
@maxtepkeev Can you help me a little with writing the test case? I think I'll have to create an equivalent function to |
@hjpotter92 Thanks again for the PR and sorry for such a delay with an answer, having hard times here... No worries about the test case, I'll write it myself. |
@maxtepkeev Thanks for merging the PR. 😄 BTW, I came across another bug because of this. The .
.
.
File "/var/task/redminelib/engines/base.py", line 74, in request
kwargs = self.construct_request_kwargs(method, headers, params, data)
File "/var/task/redminelib/engines/base.py", line 57, in construct_request_kwargs
kwargs['data'] = json.dumps(data)
File "/usr/lib64/python2.7/json/__init__.py", line 244, in dumps
return _default_encoder.encode(obj)
File "/usr/lib64/python2.7/json/encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib64/python2.7/json/encoder.py", line 270, in iterencode
return _iterencode(o, 0)
File "/usr/lib64/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <StringIO.StringIO instance at 0x7f141da69200> is not JSON serializable For now, as a workaround; I added the following when the data is being jsonified: if 'attachments' in data:
for attachment in data['attachments']:
attachment.pop('path') |
@hjpotter92 Oh I see, ok, thx for letting me know. |
Add globally available method to allow for uploading binary object
I think instead of having a different method, it can be managed by the same
upload
call.References #186.