dev@locazia: api storage upload normally work at duplicate file
This commit is contained in:
parent
86175b75e1
commit
bb959865e7
|
|
@ -35,6 +35,15 @@ async def s_api_v1_storage_post(request):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
file_hash = b58encode(hashlib.sha256(file_content).digest()).decode()
|
file_hash = b58encode(hashlib.sha256(file_content).digest()).decode()
|
||||||
|
stored_content = db_session.query(StoredContent).filter(StoredContent.hash == file_hash).first()
|
||||||
|
if stored_content:
|
||||||
|
stored_cid = stored_content.cid.serialize_v1()
|
||||||
|
return {
|
||||||
|
"content_sha256": file_hash,
|
||||||
|
"content_id_v1": stored_cid,
|
||||||
|
"content_url": f"dmy://storage?cid={stored_cid}",
|
||||||
|
}
|
||||||
|
|
||||||
new_content = StoredContent(
|
new_content = StoredContent(
|
||||||
type="local/content_bin",
|
type="local/content_bin",
|
||||||
user_id=request.ctx.user.id,
|
user_id=request.ctx.user.id,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue