Skip to content
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

Write ebook file directly into db instead file #306

Open
jaksatomovic opened this issue Apr 17, 2024 · 1 comment
Open

Write ebook file directly into db instead file #306

jaksatomovic opened this issue Apr 17, 2024 · 1 comment

Comments

@jaksatomovic
Copy link

I want to create book but instead of saving it to file and then storing it to db it would be nice to do this directly

@aerkalov
Copy link
Owner

You can do something like this. Instead of providing file name you can provide io.BytesIO object and then you can save content of that buffer from the memory to the file, database or anywhere you want. In this example I save it to the file but you can pass content of bk.getbuffer() anywhere you want.

    import io

    bk = io.BytesIO()

    epub.write_epub(bk, book, {})

    with open("book.epub", "wb") as f:
        f.write(bk.getbuffer())

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