boto3 icon indicating copy to clipboard operation
boto3 copied to clipboard

S3 client could have a file-like interface for writing objects.

Open EvanKrall opened this issue 6 years ago • 3 comments

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.

EvanKrall avatar Oct 02 '18 21:10 EvanKrall

Marking this as a feature request.

dstufft avatar Oct 08 '18 00:10 dstufft

@EvanKrall is download_fileobj what you're looking for?

tim-finnigan avatar Apr 06 '22 19:04 tim-finnigan

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.

EvanKrall avatar Apr 06 '22 21:04 EvanKrall