Output over 1MiB is passed back as an ArrayBuffer and an output file card is displayed.

This commit is contained in:
n1474335 2017-12-26 00:44:40 +00:00
parent 0e7989111f
commit af71ca6a25
7 changed files with 130 additions and 35 deletions

View file

@ -76,10 +76,15 @@ Chef.prototype.bake = async function(input, recipeConfig, options, progress, ste
progress = err.progress;
}
// Depending on the size of the output, we may send it back as a string or an ArrayBuffer.
// This can prevent unnecessary casting as an ArrayBuffer can be easily downloaded as a file.
// 1048576 bytes = 1 MiB
const returnType = this.dish.size() > 1048576 ? Dish.ARRAY_BUFFER : Dish.STRING;
return {
result: this.dish.type === Dish.HTML ?
this.dish.get(Dish.HTML) :
this.dish.get(Dish.STRING),
this.dish.get(returnType),
type: Dish.enumLookup(this.dish.type),
progress: progress,
duration: new Date().getTime() - startTime,