Fixed lots of things about storing blobs.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3680 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2021-10-31 21:15:18 +00:00
parent 08cd0ec878
commit 03a2367532
3 changed files with 49 additions and 6 deletions

View File

@ -97,6 +97,24 @@ static JSValue _tf_ssb_blobStore(JSContext* context, JSValueConst this_val, int
result = JS_NewString(context, id);
}
}
else
{
size_t offset;
size_t element_size;
JSValue buffer = tf_try_get_typed_array_buffer(context, argv[0], &offset, &size, &element_size);
if (!JS_IsException(buffer))
{
blob = tf_try_get_array_buffer(context, &size, buffer);
if (blob)
{
if (tf_ssb_db_blob_store(ssb, blob, size, id, sizeof(id)))
{
result = JS_NewString(context, id);
}
}
}
JS_FreeValue(context, buffer);
}
}
return result;
}