Librarian should have a write API for uploads
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Launchpad itself |
Won't Fix
|
Low
|
Unassigned |
Bug Description
Uploading a file to the Librarian looks like this with the current API:
file_id, file_alias = uploader.addFile(
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.
exporter.
size = filehandle.tell()
filehandle.
It would be nice if the Librarian would allow me to just do something like this:
filehandle = uploader.
exporter.
I'd imagine this is a fairly common use case.
Changed in launchpad: | |
status: | New → Accepted |
description: | updated |
visibility: | private → public |
Changed in launchpad-foundations: | |
status: | Triaged → Won't Fix |
So far, all the cases I've seen have had the size available - either form uploads, being read from the filesystem, or small files with content in a string.
As you have use cases, this could be implemented as a class in librarian/ client. py:
class Something:
def __init__(self):
[open a temporary file]
def write(self, data):
[write data to temporary file]
def close(self):
[upload the contents of the temporary file to the librarian]
[set an attribute to the newly created libraryfilealias id]