Skip to content

Can't pass an object with read() to StreamDecryptor #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Redoubts opened this issue Aug 29, 2018 · 2 comments
Closed

Can't pass an object with read() to StreamDecryptor #75

Redoubts opened this issue Aug 29, 2018 · 2 comments
Assignees

Comments

@Redoubts
Copy link

So now I'm trying to download an encrypted file, and I figured I'd pipe it through the StreamDecryptor. But when I try this, I get back

TypeError: 'StreamingBody' does not have the buffer interface

I suspect this is because in def prep_stream_data(data): (L138:internal/utils/__init__.py), my file like object is checked with isinstance(data, (file, io.IOBase, six.StringIO)). But my object is a botocore StreamingBody, which doesn't inherit from any of these. So my object gets passed to io.BytesIO and dies because it's a stream and not a buffer.

I'm not sure what this check is specifically requiring, it might be nicer to check for specific methods -- I expected anything with read() to work here.

@Redoubts Redoubts changed the title 'StreamingBody' does not have the buffer interface Can't pass an object with read() to StreamDecryptor Aug 29, 2018
@mattsb42-aws
Copy link
Member

I think the simplest solution to this is to invert what prep_stream_data is doing and rather than pass through stuff that matches a certain pattern, instead pass through anything that is not a string or bytes, and cast/wrap those.

We'll probably want to change this in the future to be more prescriptive, but before that I'll want to properly define what API we expect source streams to have and expose a helper to check that.

@mattsb42-aws
Copy link
Member

This fix is now available in version 1.3.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants