@@ -40,7 +40,8 @@ def get(self, cid: base.cid_t, **kwargs: base.CommonArgs):
40
40
return self ._client .request ('/dag/get' , args , decoder = 'json' , ** kwargs )
41
41
42
42
@base .returns_single_item (base .ResponseBase )
43
- def put (self , data : utils .clean_file_t , ** kwargs : base .CommonArgs ):
43
+ def put (self , data : utils .clean_file_t , format : str = 'cbor' ,
44
+ input_enc : str = 'json' , ** kwargs : base .CommonArgs ):
44
45
"""Decodes the given input file as a DAG object and returns their key
45
46
46
47
.. code-block:: python
@@ -63,12 +64,18 @@ def put(self, data: utils.clean_file_t, **kwargs: base.CommonArgs):
63
64
----------
64
65
data
65
66
IO stream object of path to a file containing the data to put
67
+ format
68
+ Format that the object will be added as. Default: cbor
69
+ input_enc
70
+ Format that the input object will be. Default: json
66
71
67
72
Returns
68
73
-------
69
74
dict
70
75
Cid with the address of the dag object
71
76
"""
77
+ opts = {'format' : format , 'input-enc' : input_enc }
78
+ kwargs .setdefault ('opts' , {}).update (opts )
72
79
body , headers = multipart .stream_files (data , chunk_size = self .chunk_size )
73
80
return self ._client .request ('/dag/put' , decoder = 'json' , data = body ,
74
81
headers = headers , ** kwargs )
@@ -105,7 +112,7 @@ def imprt(self, data: utils.clean_file_t, **kwargs: base.CommonArgs):
105
112
.. code-block:: python
106
113
107
114
>>> with open('data.car', 'rb') as file
108
- ... client.dag.imprt(file)
115
+ ... client.dag.imprt(file)
109
116
{'Root': {
110
117
'Cid': {
111
118
'/': 'bafyreidepjmjhvhlvp5eyxqpmyyi7rxwvl7wsglwai3cnvq63komq4tdya'
0 commit comments