Skip to content

DecryptionStream should handle simplest FileObj #80

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 Sep 5, 2018 · 2 comments
Closed

DecryptionStream should handle simplest FileObj #80

Redoubts opened this issue Sep 5, 2018 · 2 comments
Assignees

Comments

@Redoubts
Copy link

Redoubts commented Sep 5, 2018

So I'm trying to stream a download into a decryption stream, and my code looks something like this:

downloadable = self.bucket.Object(key).get()
destination = open(path_to_file, "wb")

decrypted_data = aws_encryption_sdk.stream(
            mode='d',
            source=downloadable["Body"],
            key_provider=self.static_master_key_provider
)

for chunk in decrypted_data:
    destination.write(chunk)

When I do this, I get an error after a single successful chunk read:
AttributeError: 'StreamingBody' object has no attribute 'closed'
I think it should try and handle this case (object with nothing but read and close).

Unless you think this is an inappropriate way of piping an s3 blob into the decryption streamer.

@mattsb42-aws mattsb42-aws self-assigned this Sep 5, 2018
@mattsb42-aws
Copy link
Member

I'll take a look into this. Scanning through, I think that the closed issue we can sidestep by fixing #24. However, that will still leave us depending on tell(), which StreamingBody also lacks. We might be able to sidestep that by counting the bytes read, but I'll need to dig a bit to make sure that won't break other things.

@mattsb42-aws
Copy link
Member

Sorry for the long lag on actually getting this published.

With the 1.4.0 release last week, the only required API on the source stream is now .read().

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

No branches or pull requests

2 participants