Skip to content

Instantly share code, notes, and snippets.

@osvimer
Created November 19, 2020 16:07
#!/usr/bin/env python
# vim:fileencoding=utf-8
# you may want change this
dest_url = 'https://img.vim-cn.com/'
import sys
from subprocess import Popen, PIPE
args = []
for f in sys.argv[1:]:
if f == '-':
args.extend(['-F', 'name=@-;filename=-.png'])
else:
args.extend(['-F', 'name=@'+f])
cmd = ['curl', '--compressed', dest_url] + args
p = Popen(cmd, stdout=PIPE)
ret = p.wait()
url = p.stdout.read()
sys.stdout.buffer.write(url)
sys.exit(ret)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment