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>
This commit is contained in:
parent
79b36f3bc2
commit
589c6d066f
@ -512,18 +512,23 @@ uint32_t Blob::size() const
|
|||||||
return m_blob["size"].as<uint32_t>();
|
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, std::string mimeType)
|
||||||
Blob Blob::copyFrom(const char *buffer, uint32_t size)
|
|
||||||
{
|
{
|
||||||
Uint8Array contentCopy = Uint8Array::copyFrom(buffer, size);
|
Uint8Array contentCopy = Uint8Array::copyFrom(buffer, size);
|
||||||
|
|
||||||
emscripten::val contentArray = emscripten::val::array();
|
emscripten::val contentArray = emscripten::val::array();
|
||||||
contentArray.call<void>("push", contentCopy.val());
|
contentArray.call<void>("push", contentCopy.val());
|
||||||
emscripten::val type = emscripten::val::object();
|
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));
|
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()
|
emscripten::val Blob::val()
|
||||||
{
|
{
|
||||||
return m_blob;
|
return m_blob;
|
||||||
|
@ -64,6 +64,7 @@ namespace qstdweb {
|
|||||||
public:
|
public:
|
||||||
explicit Blob(const emscripten::val &blob);
|
explicit Blob(const emscripten::val &blob);
|
||||||
uint32_t size() const;
|
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);
|
static Blob copyFrom(const char *buffer, uint32_t size);
|
||||||
emscripten::val val();
|
emscripten::val val();
|
||||||
std::string type() const;
|
std::string type() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user