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

Getting Stream in GetRequest object (Download process) #1387

Open
AbbTek opened this issue May 7, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@AbbTek
Copy link

commented May 7, 2019

I'm wondering if there is a way to get the content Stream from the GetRequest object instead of the method download that requires to copy the content into another Stream. The approach of copying is ok, but it isn't efficient when we are using the SDK in a Lambda Function where the memory is limited, and we are copying big files. We created an extension to work around this problem, but I think a solution in the same SDK would be better.

@jskeet

This comment has been minimized.

Copy link
Collaborator

commented May 7, 2019

Could you clarify exactly which GetRequest object you're talking about? (Ideally which library, too?) If it's media upload or media download, I don't believe we currently have any support for that, I'm afraid.

@jskeet

This comment has been minimized.

Copy link
Collaborator

commented May 7, 2019

(I'm happy to look into this a bit more when we have more detail about exactly what you're trying to do, but I suspect it would be very hard to expose that stream, due to retries etc that we handle transparently.)

@AbbTek

This comment has been minimized.

Copy link
Author

commented May 8, 2019

I'm attaching our solution for this problem. Having access to the stream allows us to upload (To S3) without reading the content in memory, then for large files is a better approach.

DownloadExtensions.txt

@jskeet

This comment has been minimized.

Copy link
Collaborator

commented May 8, 2019

Hmm... it's still not clear to me exactly where you'd want to fetch a stream from. The stream used in MediaDownloader is buried in the heart of the class - I think it would be very hard to make that accessible in any normal manner. We could add a separate method entirely aside from the rest of the flow (and error handling), but we couldn't add it into the IMediaDownloader interface.

An alternative for you would be to create a subclass of MediaDownloader yourself, and handle OnDataReceived by writing that data to the S3 stream... or to create a Stream implementation which did exactly that whenever it received data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.