Closed eckelj closed 1 year ago
unmarshalling from python;
from ipld import unmarshal
f = open("/home/julian/Downloads/download", "rb")
unmarshalled_asset = unmarshal(f.read())
print(unmarshalled_asset)
with: https://bafkreiftyhhknkdvbjjlr5n55sjnekpr7kkvwzekoekk2figxk3lp7ta5y.ipfs.w3s.link/
{'StatusSNS': {'ENERGY': {'ApparentPower': 36, 'Current': 0.152, 'Factor': 0.48, 'Power': 17, 'ReactivePower': 31, 'Today': 0.134, 'Total': 73.416, 'TotalStartTime': '2022-10-20T14:13:01', 'Voltage': 234, 'Yesterday': 0.429}, 'Time': '2023-04-18T07:30:02'}}
I stumbled upon this: https://github.com/ipld/js-ipld and it's successor: https://github.com/multiformats/js-multiformats/tree/v9.5.3
Both are not implementing the unmarshal method from py-ipld.
@eckelj can we switch to another serialization method?
From standup: try to to use raw/json data directly for creating the ipfs hash
Alternative: use the cid-resolver for unmarshalling
This example from the official CID Inspector https://cid.ipfs.tech/#bafybeigrf2dwtpjkiovnigysyto3d55opf6qkdikx6d65onrqnfzwgdkfa shows that there is image data behind the CID: https://bafybeigrf2dwtpjkiovnigysyto3d55opf6qkdikx6d65onrqnfzwgdkfa.ipfs.dweb.link/
So chances are we can use JSON directly.
The CID page shows the marshalled CID data. In python the ipld - marshal method is used. we need to identify the corresponding JS method to unmarshal the data.