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

attachable bytes #380

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

attachable bytes #380

wants to merge 2 commits into from

Conversation

laf-rge
Copy link
Contributor

@laf-rge laf-rge commented Mar 16, 2025

Add support for byte stream attachments

This PR adds support for attaching files using byte streams alongside the existing file path method.

Fixes #368

Changes

  • Added _FileBytes attribute to the Attachable class to support byte stream attachments
  • Updated make_request in QuickBooks client to handle file bytes
  • Added validation to ensure only one of _FilePath or _FileBytes is used at a time
  • Added new integration test test_create_file_from_bytes to verify functionality
  • Updated documentation with examples of the new byte stream attachment method

Example Usage

python attachment = Attachable() attachment.FileName = 'document.pdf' attachment.FileBytes = pdf_bytes # bytes object containing file content attachment.ContentType = 'application/pdf' attachment.save(qb=client)

Benefits

  • Enables direct attachment of in-memory file content without writing to disk
  • Useful for handling file uploads, generated PDFs, and other byte stream content
  • Maintains backward compatibility with existing file path method

Testing

  • Added integration test verifying byte stream attachment functionality
  • Existing file path attachment tests continue to pass
  • All integration tests passing except for unrelated Account test failures

Documentation

  • Added new section in README.md demonstrating byte stream attachment usage
  • Added note clarifying mutual exclusivity of _FilePath and _FileBytes

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

Successfully merging this pull request may close these issues.

Change Attachment interface to allow bytes instead of file path
1 participant