Comments (7)
Since I was the one who first requested iter_content()
, I can say that this change makes a lot of sense to me. The use case I had at the time was precisely
retrieving large files in the background without having to load all the data into memory.
Also, I have had one user with two of my workflows have issues, and in both instances the problem was his spotty internet connection. Saving the response data to file ought to allow me to fix this problem. So, I say yes.
from alfred-workflow.
You were indeed the one who requested it, but I've no idea if you're the only one using itβ¦
I don't think it'd help with a spotty Internet connection, however. I have no intention of implementing range headers etc. to enable continuing interrupted downloads.
from alfred-workflow.
Firstly, it's possible to decompress a stream in python which you can find an implementation here.
And here is my sample code. Don't have any web server so test it with a local file stream.
import zlib
def decompress(stream):
d = zlib.decompressobj(16 + zlib.MAX_WBITS)
for chunk in stream:
rv = d.decompress(chunk)
if rv:
yield rv
For save_to_files()
, I think it's an interesting feature not just for gzip file. For example, it can be used to download a audio file which will be played later. Always cache large file sounds like a reasonable idea.
However, there are always some scenarios that people don't want cache at all. e.g. A API provider may not allow user to cache anything they got. So my idea is having a save_path=None
parameter and save response to file if it's not None
. Or we can just leave it to user because save a stream to file isn't something very difficult.
from alfred-workflow.
Good find wrt zlib
. I'd only looked at the gzip
module, which doesn't work with the response objects from urllib
.
I've tested it with a webserver and it works great. So iter_content()
doesn't need replacing.
Might still be worth adding a save_to_path()
method alongside it, however.
from alfred-workflow.
save_to_path()
is a really good idea, I'm 100% support it.
from alfred-workflow.
Agreed.
from alfred-workflow.
Gzip support and save_to_path()
implemented in v1.9.6
from alfred-workflow.
Related Issues (20)
- Run with error HOT 2
- Cache Image HOT 5
- Basic auth HOT 3
- Pass parameter to subprocess HOT 5
- Tutorial options for keywords need to be updated for Alfred 4 HOT 11
- set_config raises error when the bundle id is null HOT 4
- Setting only arg on Variables adds line break HOT 1
- will it support python3? HOT 1
- python3 has no cpickle HOT 1
- cant get output HOT 11
- chr() arg not in range(256) error when trying to use Beautiful Soup 4 HOT 1
- workflow:magic not working?
- API functionality question
- AlertCautionIcon.icns does not exist on Big Sur
- ERROR: [Script Filter] JSON error
- Google SDK
- Can't get Script Filter to find the pinboard.py file from the tutorial HOT 1
- [Feature request] Possible to open bookmarks from root?
- Not working on the latest MacOS 12.3 HOT 11
- How to fetch chrome cookie?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alfred-workflow.