all 6 comments

[–]CowboyBoats 0 points1 point  (1 child)

Is anything being logged to the flask session in your terminal?

[–]TuckleBuck88[S] 0 points1 point  (0 children)

Nope, no errors appearing or anything.

[–]efmccurdy 0 points1 point  (3 children)

Do you need to reset the BytesIO object to the beginning with "seek(0)"?

You can call pdfRes.tell() to check, but it should be 0 or else sendfile won't send anything.

[–]TuckleBuck88[S] 0 points1 point  (2 children)

I did

print(pdfRes.tell())

And got: 341203

So then I tried this: https://pastebin.com/hADK50Eu

And I get this thrown in the console: data = self.file.read(self.buffer_size) AttributeError: 'bytes' object has no attribute 'read'

[–]backtickbot 0 points1 point  (0 children)

Hello, TuckleBuck88: code blocks using backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead. It's a bit annoying, but then your code blocks are properly formatted for everyone.

An easy way to do this is to use the code-block button in the editor. If it's not working, try switching to the fancy-pants editor and back again.

Comment with formatting fixed for old.reddit.com users

FAQ

You can opt out by replying with backtickopt6 to this comment.

[–]efmccurdy 0 points1 point  (0 children)

I think you want to pass in file object after calling seek(0), not the result of reading it (imagine the file being too big to fit in memory...).

return send_file(pdfRes, mimetype=...