Message8212
A new method determine_output_format(self, uri) was added in issue 2551289 to refactor
the dispatch method.
One thought could be to modify determine_output_format() to check for a trailing
'binary_content' element in the path. For example:
curl -X GET -u admin -H "Accept: image/png" -H "X-Requested-With: rest" \
https://example.com/tracker/rest/data/file/54/binary_content
results in:
self.client.request.path '/tracker/rest/data/file/54/binary_content'
Parsing the path and splitting the designator allows getting the mime type of the file
via self.client.db.file.get('54', 'type') -> 'image/png'
This can be compared to the Accept header in the `for part in accept_header:`
loop by adding:
if part[0] == file_type:
accept_type = file_type
this should result in a call to get_attribute(self, class_name, item_id, attr_name, input)
which returns the binary data in a dict. Which then calls format_dispatch_output().
Then changing format_dispatch_output(self, accept_mime_type, output, pretty_print)
to add the right content type header and return the output['data']['data'] element
if the accept_mime_type is defined. (Note: accept_mime_type should never be
undefined/None with the change to fix issue 2551289.)
Also in the debugger using open('file', 'wb').write(output['data']['data'] wrote
my test png file just fine. Just need to make sure I can write raw binary data to
the http socket. |
|
Date |
User |
Action |
Args |
2024-12-08 07:18:00 | rouilj | set | messageid: <1733642280.2.0.790531767091.issue2551068@roundup.psfhosted.org> |
2024-12-08 07:18:00 | rouilj | set | recipients:
+ rouilj, schlatterbeck |
2024-12-08 07:18:00 | rouilj | link | issue2551068 messages |
2024-12-08 07:18:00 | rouilj | create | |
|