Perhaps you could create a branch in your current fork and push a commit there, then create a pull request to safepublishing/rfcs? I never tried that, but maybe it could work…
From the Rust perspective, the most intuitive type might be the
std::io::Read trait. It’s implemented by
[u8]. It has a streaming variant too,
BufRead. So perhaps two
add functions, one accepting
Read, the other
string | Uint8Array | ReadableStream (Node.js’s
Buffer is also an
files_container_* methods seem to infer the
Content-Type HTTP header (in the SAFE network FilesMaps this is stored in the value
type.) A .html file will have the type
text/html and it’s essentially a 1-to-1 mapping of MIME types for traditional file types.
If you use the
files_container_add_from_raw function, it stores the type as
type: "Raw", even if the call you make contains a valid file type for it to hint from:
v.files_container_add_from_raw(new Uint8Array([104, 101, 108, 108, 111]), "hnyynyi95mmtqr9pcwnoft9xwo61w3iu7qmhd415yngihakc1ajrgkiq4ebnc/test.html", true, false, false); /test.html: created: "2020-02-13T22:49:40Z" link: "safe://hbyyyynow943e9j4iwuspmobswb7dmstbzt1d51cssqfsmiun7zjxzrhc8" modified: "2020-02-13T22:49:40Z" size: "" type: "Raw"
Do you think it’s worth me adding a change to this method in this RFC to allow the setting of the
A signature along the lines of:
v.files_container_add_from_raw(buffer, url, force, update_nrs, type, dry_run); // Example call: v.files_container_add_from_raw( new Uint8Array([104, 101, 108, 108, 111]), "hnyynyi95mmtqr9pcwnoft9xwo61w3iu7qmhd415yngihakc1ajrgkiq4ebnc/test.html", true, false, "text/html; charset=utf-8", false );
It’s also not storing the file size of Raw files in the FilesMap (though it is presenting a valid
Content-Length header on download), this is presumably some kind of bug?
Yep, I think an arg for setting the type is what’s needed there
size does indeed sound buggy.