Conversation
This new function downloads an attachment directly to disk instead of to memory. It is useful for two reasons: * If the user wants to save the attachment to a file anyway, it turns several lines of user code into one line. * If the file is very large, storing the attachment in memory before writing it to a file can fill all the available memory in the system.
|
Thanks Adam. That's a good idea. We'll take a look shortly and see how it shakes out. Thanks too for the doc contribution (always nice to save some time!). cheers, |
|
Whats the status of this? Seems like its been a while since this has been looked at and i can not find anything in the API that would have replaced this. Can we get this merged into the main codebase? |
|
Hi, sorry for the delay, we lost track of this one. We'll discuss the approach in our pipeline meeting tomorrow and report back. Matt |
|
We talked through this today and have scheduled it for our next sprint starting next week. We want to make a couple of minor adjustments, but overall it looks good. Thanks for the pull request. We'll update you next week. cheers, |
|
Hey Brandon, could you please code review and merge? Thanks! |
…wnload_attachment 22152 support hash for download attachment (and Pull #32 write directly to disk)
|
We've tagged and released v3.0.14 which includes a modified version of this pull request. We opted to have it as an optional parameter on the existing Thanks a lot for submitting this! (we gave you credit in the Changelog). |
I want to download some large files (1+ GB) from a Shotgun server. With the download_attachment() function, the whole file must be stored in memory before it can be saved to the disk. This is a problem because there might not be that much RAM available on the system I'm running the script on.
This commit adds a new function, download_attachment_to_file(), which streams the attachment directly to a file. It uses very little memory, no matter how large the file is.
I have tested the changes in Python 2.4.6 and 2.7.3, in Linux and Windows.
I'm not sure what the best way is to submit documentation changes, so here's a gist with Markdown documentation for the Methods Reference page on the wiki:
https://gist.github.com/4490286