diff options
author | Lorn Potter <lorn.potter@gmail.com> | 2023-04-17 16:22:49 +1000 |
---|---|---|
committer | Lorn Potter <lorn.potter@gmail.com> | 2023-04-21 06:18:32 +1000 |
commit | 589c6d066f84833a7c3dda1638037f4b2e91b7aa (patch) | |
tree | 427742312f35e9aafb0eb064aba4cf60c66f2d65 /src/corelib/platform | |
parent | 79b36f3bc24ebcd649e8b7683b51bd70c08477c6 (diff) |
wasm: add setting type to Blob
Blobs can be any mime type, add function that sets up mime type
This allows Safari to play videos that are Blobs
Pick-to: 6.5
Change-Id: Ide63851934058935d94f42721b246d832e3bcb85
Reviewed-by: MikoĊaj Boc <Mikolaj.Boc@qt.io>
Diffstat (limited to 'src/corelib/platform')
-rw-r--r-- | src/corelib/platform/wasm/qstdweb.cpp | 11 | ||||
-rw-r--r-- | src/corelib/platform/wasm/qstdweb_p.h | 1 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/corelib/platform/wasm/qstdweb.cpp b/src/corelib/platform/wasm/qstdweb.cpp index 78e0bb83ab..1ffa3ca8f3 100644 --- a/src/corelib/platform/wasm/qstdweb.cpp +++ b/src/corelib/platform/wasm/qstdweb.cpp @@ -512,18 +512,23 @@ uint32_t Blob::size() const return m_blob["size"].as<uint32_t>(); } -// Copies content from the given buffer into a Blob object -Blob Blob::copyFrom(const char *buffer, uint32_t size) +Blob Blob::copyFrom(const char *buffer, uint32_t size, std::string mimeType) { Uint8Array contentCopy = Uint8Array::copyFrom(buffer, size); emscripten::val contentArray = emscripten::val::array(); contentArray.call<void>("push", contentCopy.val()); emscripten::val type = emscripten::val::object(); - type.set("type","application/octet-stream"); + type.set("type", std::move(mimeType)); return Blob(emscripten::val::global("Blob").new_(contentArray, type)); } +// Copies content from the given buffer into a Blob object +Blob Blob::copyFrom(const char *buffer, uint32_t size) +{ + return copyFrom(buffer, size, "application/octet-stream"); +} + emscripten::val Blob::val() { return m_blob; diff --git a/src/corelib/platform/wasm/qstdweb_p.h b/src/corelib/platform/wasm/qstdweb_p.h index e01a5bd855..1b832319e0 100644 --- a/src/corelib/platform/wasm/qstdweb_p.h +++ b/src/corelib/platform/wasm/qstdweb_p.h @@ -64,6 +64,7 @@ namespace qstdweb { public: explicit Blob(const emscripten::val &blob); uint32_t size() const; + static Blob copyFrom(const char *buffer, uint32_t size, std::string mimeType); static Blob copyFrom(const char *buffer, uint32_t size); emscripten::val val(); std::string type() const; |