-
Notifications
You must be signed in to change notification settings - Fork 162
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
Enhancement: Enable use of Readable stream when uploading attachments #631
Comments
PETOSS-272 |
Thanks for raising an issue, a ticket has been created to track your request |
Any updates on this? Is the approach described above to temporarily write the buffer to disk before reading it again as a FS stream still the only workaround? |
The changes to accept Buffer & Readable stream type has been released with the new version v5.1.0 Please let us know with any more issues. |
Thanks for the update! However, I don't think it's working. When I perform an export, the file is not attached to the invoice. I have a unit test that proves that the document stream passed into the Example effected invoices:
The below examples were imported into Xero, the first using the latest version of the xero-node SDK and the second using version 4.17.0 Additionally, I am seeing a console.log message If I can help any further please let me know |
SDK you're using (please complete the following information):
Is your feature request related to a problem? Please describe.
Currently, the accounting API allows for attaching documents by using a file stream. This relies on the file existing on disk in order to use the
fs.ReadStream
API.Because of this restriction, when auto generating a document receipt in memory, it is necessary to write the file to disk before we can use the
fs.createReadStream(...)
method to pass the file onto the Xero Accounting API client (in my specific case theupdateInvoiceAttachmentByFileName
method).Describe the solution you'd like
The
readStream
argument uses the typefs.ReadStream
. I propose that we define this argument as a union type offs.ReadStream | Readable | Buffer
or define an overloaded method (to maintain backward compatibility) and use the Stream API to enable the use ofReadable
streams. An example of this would look like:Describe alternatives you've considered
The only alternative currently is to temporarily write the buffer to disk before reading it into an FS stream, which is pretty inefficient.
Additional Context
I'd be happy to submit a PR for this if someone could point me in the right direction. It doesn't look super clear how this would be done using the Open API generator
The text was updated successfully, but these errors were encountered: