通过scp将数据上载到远程www目录并返回公共url。
drop的Python项目详细描述
通过scp将数据上载到远程www目录并返回公共url。
安装
最简单的方法是通过pip安装:
pip install drop
目前除了Python2.7或Python3.4之外,没有其他依赖项。
要手动安装:将drop/drop.py复制到您喜欢的任何位置
配置
配置文件是必需的,它可以位于/etc/drop.cfg、~/.drop.cfg或通过命令行选项-config file传递的位置。
示例配置文件是:
[DEFAULT] # reference to the default destination (section name): destination = hawo # You can set the following defaults: # Location of the scp command, can be relative or absolute path: scp = scp # default length (in characters) for hashfilenames (max. 28) hashlength = 28 # default chmod to apply to uploaded files (already applied localy and uploaded with -p) # 436 this is 0o644 chmod = 436 # Destinations: [hawo] # remote server dns or alias from .ssh/config and may also include username (user@server): remoteserver = ente # remote directory can be relative (to home directory) or absolute: remotedir = public_html/d/ # publishing url, this must represent the above directory: url = http://hawo.net/~sijuhamm/d/ # all defaults can be overwritten for any destination. For example the hashlength: hashlength = 10
默认部分为所有其他部分和默认目标配置默认值。所有其他部分都称为目的地部分。可以通过–destination命令行参数选择它们。
用法
您可以按参数发送文件:
$ drop defaults.cfg http://hawo.net/~sijuhamm/d/NcT0jFb5.cfg
或通过stdin的任何内容:
$ date | ./drop.py http://hawo.net/~sijuhamm/d/ephtK9DY
远程位置的文件名实际上是文件的部分sha1校验和。校验和的长度可以在配置文件中设置。尽可能保留扩展名,也可以使用–extension参数覆盖扩展名。
完整的帮助信息如下:
usage: drop [-h] [--destination DESTINATION] [--list-destinations] [--preserve-name] [--extension EXTENSION] [--config-file CONFIG_FILE] [--test] infile [infile ...] Uploads data to a remote www directory via scp and returns a public url. positional arguments: infile File to upload. If multiple are passed, they will be archived and compressed before uploading. optional arguments: -h, --help show this help message and exit --destination DESTINATION, -d DESTINATION Name of destination as found in configuration file. --list-destinations, -l List all destinations defined in configuration file. --preserve-name, -p Will preserve original filename at remote location, by adding an intermediate directory. --extension EXTENSION, -e EXTENSION Overwrites extension on uploaded file. --config-file CONFIG_FILE, -c CONFIG_FILE --test Runs a test on destination.
待办事项
- 即将推出的功能:
- (可能)支持其他上传目的地
- 支持更多压缩/存档格式