You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GetObject on any sufficiently large object succeeds (with no complains in logs on max level) but GetBody().read() returns false. To my surprise GetObject apparently buffers entire response into memory buffer and does not return control to caller until entire object payload is downloaded. And when it rans out of memory -- it silently succeeds, but reading from related iostream fails with no error code or explanations.
What is the point of using iostreams if GetObject result keeps all data in memory? Why not give me direct access to that memory so that I avoid expensive layer of iostream logic?
Is there any way to get smth more meaningful in code and/or logs than simple false from read()?
Why GetObject waits for entire payload to be loaded into memory before returning to caller? You'd expect it to return early and resulting iostream would read data from underlying socket allowing me to avoid buffering entire object in memory.
Reacted by Jean-Philippe Bergeron and TE-501200A121
Nevermind... I've found AmazonWebServiceRequest::SetResponseStreamFactory() and this:
// NOTE: If using an FStream in order to download a file from S3 to a physical file, then we need to specify
// the filemode "std::ios_base::out | std::ios_base::in | std::ios_base::trunc" --
// If the file transfer fails, then the error stream from the httpRequest is written to the file instead of the
// actual file contents.
// If this is the case, then the BuildAWSError function assumes it can 'read' the stream in order to read in the
// error status and create an AWSError. If the file is not marked as read/write (or write only), this will fail
// and the error status will instead be an XML_PARSE_ERROR error because the BuildAWSError function failed
// The 'truncate' is required to ensure that if the file download IS successful, then it can be written to the
// FStream (if ::trunc is not specified, then the FStream.write fails for some unknown reason)
So, basically, for me to be able to stream data into my "sink" I need to implement a stream that supports both output and input. In light of this being non-trivial (especially when sink is not a file on local drive) and related problems with request-timeout I simply implemented download as a sequence of GetObject requests that download data piece-by-piece.
Activity
crusader-mike commentedon Nov 3, 2017
Nevermind... I've found
AmazonWebServiceRequest::SetResponseStreamFactory()and this:So, basically, for me to be able to stream data into my "sink" I need to implement a stream that supports both output and input. In light of this being non-trivial (especially when sink is not a file on local drive) and related problems with request-timeout I simply implemented download as a sequence of GetObject requests that download data piece-by-piece.
Doxygen links and shortbread fix (#715)