[HTML5] Add easy to use download API.

New `JavaScript.download_buffer` method to create a prompt that let the
user download a file.
This commit is contained in:
Fabio Alessandrelli 2021-05-19 15:53:04 +02:00
parent 8c2beeea90
commit fdf66a21f1
8 changed files with 51 additions and 61 deletions

View file

@ -70,6 +70,7 @@ void JavaScript::_bind_methods() {
mi.arguments.push_back(PropertyInfo(Variant::STRING, "object"));
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "create_object", &JavaScript::_create_object_bind, mi);
}
ClassDB::bind_method(D_METHOD("download_buffer", "buffer", "name", "mime"), &JavaScript::download_buffer, DEFVAL("application/octet-stream"));
}
#if !defined(JAVASCRIPT_ENABLED) || !defined(JAVASCRIPT_EVAL_ENABLED)
@ -100,3 +101,7 @@ Variant JavaScript::_create_object_bind(const Variant **p_args, int p_argcount,
return Ref<JavaScriptObject>();
}
#endif
#if !defined(JAVASCRIPT_ENABLED)
void JavaScript::download_buffer(Vector<uint8_t> p_arr, const String &p_name, const String &p_mime) {
}
#endif