Fetching binary data of the stored recording#184
Open
yallxe wants to merge 1 commit intoCyCoreSystems:mainfrom
Open
Fetching binary data of the stored recording#184yallxe wants to merge 1 commit intoCyCoreSystems:mainfrom
yallxe wants to merge 1 commit intoCyCoreSystems:mainfrom
Conversation
Ulexus
reviewed
Aug 7, 2025
Member
Ulexus
left a comment
There was a problem hiding this comment.
Thanks for your submission; I just have one concern regarding the functionality of Download with respect to closing the request's Body. I have made an inline suggestion, but let me know your thoughts.
|
|
||
| // Download retrieves the data for the stored recording | ||
| // IMPORTANT: Don't forget to close the reader when done. | ||
| func (sr *StoredRecording) Download(key *ari.Key) (*ari.StoredRecordingBinaryData, error) { |
Member
There was a problem hiding this comment.
This presents a quandary: it's too easy to forget to close the body's ReadCloser.
I see three ways to mitigate this, each with their own trade-offs:
- rename
DownloadtoReadCloser, in an attempt to make it clear that it must be Closed - take an
io.Writeras a second parameter toDownload() - store the download to a temp file
Personally, I think the safest and cleanest is to pass in an io.Writer; let the caller indicate where the data should go, so it can just be Piped directly there, and we can close the Body within Download.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements
GET /recordings/stored/{recordingName}/fileARI request.This change is