aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/blob.cpp
blob: 0f255d7c89602541f22c9bdad0892d68d0315d6f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "blob.h"
#include "ZigGeneratedClasses.h"

extern "C" JSC::EncodedJSValue Blob__create(JSC::JSGlobalObject* globalObject, void* impl);
extern "C" void* Blob__setAsFile(void* impl, BunString* filename);

namespace WebCore {

JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, WebCore::Blob& impl)
{
    BunString filename = Bun::toString(impl.fileName());
    impl.m_impl = Blob__setAsFile(impl.impl(), &filename);

    return JSC::JSValue::decode(Blob__create(lexicalGlobalObject, Blob__dupe(impl.impl())));
}

JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, Ref<WebCore::Blob>&& impl)
{
    auto fileNameStr = impl->fileName();
    BunString filename = Bun::toString(fileNameStr);

    EncodedJSValue encoded = Blob__create(lexicalGlobalObject, impl->impl());
    JSBlob* blob = jsCast<JSBlob*>(JSC::JSValue::decode(encoded));
    Blob__setAsFile(blob->wrapped(), &filename);

    return JSC::JSValue::decode(encoded);
}

}
e-experiment&id=cf12d80f5eab9989d01aa61c88aba326ce5fe71f&follow=1'>fs.zig: create temp files with 0o700, not 0o007 (#4107)Gravatar Adhityaa Chandrasekar 1-1/+1 2023-08-10Update remix guideGravatar Colin McDonnell 1-2/+4 2023-08-10zig fmtGravatar Jarred Sumner 1-4/+4 2023-08-10Fixes #4062 (#4106)Gravatar Jarred Sumner 8-26/+87 2023-08-10bun test: format description of test.each (#4092)Gravatar Jacques 3-13/+311 2023-08-10add util.formatWithOptions (#4090)Gravatar dave caruso 3-9/+30 2023-08-10Fix titleGravatar Colin McDonnell 1-1/+1