_artifact: use _TempTextBuffer instead of tmp file

When adding public data to CAS, save on file I/O by passing an in-memory
buffer to _cas.add_object() instead of a filename to read. This means
that we avoid reading back the file from disk when hashing it, we still
only write it to disk once.

This also side-steps a win32 compatability issue, the 'name' member of
tempfile.NamedTemporaryFile cannot be opened on Windows NT or later, as
per the Python docs:
https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile
1 file changed