File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -143,3 +143,26 @@ client = CloudantV1.new_instance(service_name="YOUR_SERVICE_NAME")
143143client.set_enable_gzip_compression(False )
144144...
145145```
146+
147+ ### Attachments with ` content-type: application/json `
148+
149+ Calling [ ` get_attachment ` ] ( https://ibm.github.io/cloudant-python-sdk/docs/latest/apidocs/ibmcloudant/ibmcloudant.cloudant_v1.html#ibmcloudant.cloudant_v1.CloudantV1.get_attachment )
150+ typically returns a ` DetailedResponse ` with ` BinaryIO ` result.
151+ For attachments uploaded with a ` content-type: application/json `
152+ header or as a ` .json ` file in the dashboard then calls to ` get_attachment `
153+ return a ` DetailedResponse ` with, for example, a ` dict ` result for a JSON
154+ object.
155+ The JSON is automatically loaded by the underlying SDK core
156+ and client to the default Python object types.
157+
158+ To get a ` BinaryIO ` result with an ` application/json ` attachment
159+ pass ` stream=True ` on the ` get_attachment ` request.
160+
161+ ``` python
162+ json_attachment: bytes = service.get_attachment(
163+ db = ' products' ,
164+ doc_id = ' 1000042' ,
165+ attachment_name = ' product_details.json' ,
166+ stream = True
167+ ).get_result().content # content bytes that can be decoded
168+ ```
You can’t perform that action at this time.
0 commit comments