dev@locazia: migrate to cidv2
This commit is contained in:
1 parent
3fdc9ada39
commit
606ef553bc
4 files changed
+98
-17
No files matched your search
@@ -119,14 +119,14 @@ async def s_api_v1_blockchain_send_new_content_message(request):
|
||||
.store_ref(
|
||||
begin_cell()
|
||||
.store_uint(1, 8)
|
||||
.store_bytes(f"{PROJECT_HOST}/api/v1/storage/{metadata_content.cid.serialize_v1()}".encode())
|
||||
.store_bytes(f"{PROJECT_HOST}/api/v1/storage/{metadata_content.cid.serialize_v2()}".encode())
|
||||
.end_cell()
|
||||
)
|
||||
.store_ref(
|
||||
begin_cell()
|
||||
.store_ref(begin_cell().store_bytes(f"{encrypted_content_cid.serialize_v1()}".encode()).end_cell())
|
||||
.store_ref(begin_cell().store_bytes(f"{image_content_cid.serialize_v1() if image_content_cid else ''}".encode()).end_cell())
|
||||
.store_ref(begin_cell().store_bytes(f"{metadata_content.cid.serialize_v1()}".encode()).end_cell())
|
||||
.store_ref(begin_cell().store_bytes(f"{encrypted_content_cid.serialize_v2()}".encode()).end_cell())
|
||||
.store_ref(begin_cell().store_bytes(f"{image_content_cid.serialize_v2() if image_content_cid else ''}".encode()).end_cell())
|
||||
.store_ref(begin_cell().store_bytes(f"{metadata_content.cid.serialize_v2()}".encode()).end_cell())
|
||||
.end_cell()
|
||||
)
|
||||
.end_cell()
|
||||
|
||||
@@ -41,10 +41,12 @@ async def s_api_v1_storage_post(request):
|
||||
stored_content = request.ctx.db_session.query(StoredContent).filter(StoredContent.hash == file_hash).first()
|
||||
if stored_content:
|
||||
stored_cid = stored_content.cid.serialize_v1()
|
||||
stored_cid_v2 = stored_content.cid.serialize_v2()
|
||||
return response.json({
|
||||
"content_sha256": file_hash,
|
||||
"content_id_v1": stored_cid,
|
||||
"content_url": f"dmy://storage?cid={stored_cid}",
|
||||
"content_id": stored_cid_v2,
|
||||
"content_url": f"dmy://storage?cid={stored_cid_v2}"
|
||||
})
|
||||
|
||||
if request.ctx.user:
|
||||
@@ -71,11 +73,13 @@ async def s_api_v1_storage_post(request):
|
||||
await file.write(file_content)
|
||||
|
||||
new_content_id = new_content.cid
|
||||
new_cid = new_content_id.serialize_v1()
|
||||
new_cid_v1 = new_content.serialize_v1()
|
||||
new_cid = new_content_id.serialize_v2()
|
||||
|
||||
return response.json({
|
||||
"content_sha256": file_hash,
|
||||
"content_id_v1": new_cid,
|
||||
"content_id": new_cid,
|
||||
"content_id_v1": new_cid_v1,
|
||||
"content_url": f"dmy://storage?cid={new_cid}",
|
||||
})
|
||||
except BaseException as e:
|
||||
@@ -107,8 +111,4 @@ async def s_api_v1_storage_decode_cid(request, content_id=None):
|
||||
if errmsg:
|
||||
return response.json({"error": errmsg}, status=400)
|
||||
|
||||
return response.json({
|
||||
"content_hash": b58encode(cid.content_hash).decode(),
|
||||
"onchain_index": cid.onchain_index,
|
||||
"accept_type": cid.accept_type,
|
||||
})
|
||||
return response.json(cid.json_format())
|
||||
Reference in new issue
Block a user