boto3
boto3 copied to clipboard
S3 client could have a file-like interface for writing objects.
I'm aware of s3.upload_fileobj()
, but this has the inverse of the interface I want. upload_fileobj
takes a file-like object with a read
method, and calls that. I'd like an interface something like this:
with s3.put_object('/path/to/object') as o:
json.dump(something, o)
# or numpy.save(o, arr)
# or pickle.dump(something, o)
# or yaml.dump(data, o)
Many libraries, like the examples above, expect a writable file-like object to be passed into them. Fewer libraries return a file-like object that can be used with upload_fileobj
.
Marking this as a feature request.
@EvanKrall is download_fileobj what you're looking for?
That's sort of the inverse of what I'm asking for -- download_fileobj
/ upload_fileobj
take a file-like object and write/read the contents of an S3 object to/from it, but I'm asking for a context manager which would give me a file-like object for my code to write into.