The Librarian reads the file from the provided filehandle. However, if the code that's producing the file is oriented towards writing it to a file-like object, the file must be stored in a temporary location and its size calculated before the upload can be done.
Uploading a file to the Librarian looks like this with the current API:
file_id, file_alias = uploader.addFile(
name=filename,
file=filehandl e,
contentType= 'application/ octet-stream' )
size=size,
The Librarian reads the file from the provided filehandle. However, if the code that's producing the file is oriented towards writing it to a file-like object, the file must be stored in a temporary location and its size calculated before the upload can be done.
I have some code that does just that:
filehandle = tempfile. TemporaryFile( ) export_ tarball_ to_file( filehandle) seek(0)
exporter.
size = filehandle.tell()
filehandle.
It would be nice if the Librarian would allow me to just do something like this:
filehandle = uploader. uploadFilehandl eFrob(
name=filename,
contentType= 'application/ octet-stream' ) export_ tarball_ to_file( filehandle)
exporter.
I'd imagine this is a fairly common use case.