Skip to content

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

@ej2 ej2 changed the base branch from master to 0.9.12 April 15, 2025 23:32
@ej2 ej2 merged commit 5efc535 into ej2:0.9.12 Apr 15, 2025
6 checks passed
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

2 participants