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>();
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user