使用www.filemail.com进行文件传输的python命令行工具和api
pyfilemail的Python项目详细描述
欢迎使用PyFileMail的文档!
pyfilemail是一个命令行工具和api,用于发送和接收带有Filemail的文件 基于requests和filemail的API。
为了避免对api密钥的唠叨,您应该注册并获得一个here。 如果您注册了付费计划,您将解锁所有功能,并将能够添加/删除/更新您的转账/联系人/组/公司设置。 如果不注册,您仍然可以作为自由计划用户发送文件,但请记住在命令行工具中使用--free参数。
有关不同计划的详细信息,请转到Filemail
我试图让这个api尽可能简单,并依赖filemail自己的数据验证来让您保持正常:) 原因是我不在filemail工作,也不知道他们对传递的数据进行了什么样的验证。 这也为我节省了大量的头疼写石头坚实的验证代码,我认为这是一个更灵活的方式,如果邮件组决定改变 任何形式的api。
来自pyfilemail.User和pyfilemail.Transfer类的appart,来自filemail的所有返回对象都是基于json响应的dict对象。
到目前为止,这已经在ubuntu 16.04上开发和测试过了。 我会尝试在windows和osx机器上操作,并添加代码以确保它在那里也能正常工作。
api文档可在readthedocs
任何反馈都非常欢迎,请通过github报告错误
安装
pip install pyfilemail
免责声明
我自己使用此软件,但还没有遇到损坏的文件,但我对使用pyfilemail发送或接收的文件不承担任何责任,无论它是内容还是文件通过的状态。 PyFileMail仍在进行中,随着我进一步开发和测试,部分API可能会发生更改。
命令行示例
pyfilemail \ --from myemail@somedomain.com \ --to lucky.b@receiver.com \ --free \ --subject "Amazing document!"\ --message "Have you seen how amazingly big this document is?"\ --payload /path/to/file.ext /path/to/folder/
添加API键
您可以使用--add-api-keyargumet将api密钥添加到本地配置文件中。
pyfilemail --add-api-key YOUR-API-KEY-FROM-FILEMAIL
netrc
您可以使用.netrc文件存储登录信息。请确保将访问限制为只允许您自己的用户阅读。
#$HOME/.netrc example:
machine yourfilemailuser@email.com
login yourfilemailuser@email.com
password topsecretpassword
命令行帮助
usage: pyfilemail [-h][--version][--add-api-key ADD_API_KEY][--free][-nc][--compress][--confirm][--quiet][--days 3][--downloads 0][--message MESSAGE][--notify][--subject SUBJECT][--to recipient@receiver.com [recipient@receiver.com ...]][--password PASSWORD][--from USERNAME][--store-password][--delete-password][--payload PAYLOAD [PAYLOAD ...]] Command line Filemail transfer through Python optional arguments: -h, --help show this help message and exit --version show program's version number and exit --add-api-key ADD_API_KEY Add API KEY from Filemail to local config file --free Send files without a registered Filemail account -nc, --no-checksum Skip calculating checksum on added files --compress Compress (ZIP) data before sending? --confirm Email confirmation after sending the files? --quiet Log only warnings to console --days 3 Number of days the file(s) are available for download --downloads 0 Number of times the file(s) may be downloaded. 0=unlimited --message MESSAGE Message to the recipient(s) of the transfer --notify Notify when recipients download your files? --subject SUBJECT Subject of email sent with transfer --to recipient@receiver.com [recipient@receiver.com ...] Recipient(s) of the transfer (email addresses) --password PASSWORD Protect transfer with the supplied password --from USERNAME Your email address --store-password Store user password in keychain if available --delete-password Delete password stored in keychain --payload PAYLOAD [PAYLOAD ...] File(s) and/or folder(s) to transfer
python api示例
importpyfilemail# Setup a transfer# Initialize Filemail with as free (as in free beer) useruser=pyfilemail.User(username='user@mailprovider.com')transfer=pyfilemail.Transfer(user,to='lucky@recipient.com',subject='My BIG file no email can handle',message='You will not belive the speed of this download!',notify=True,confirmation=True,days=7,password='JuSt2BeSaf£')# Add a single file to transfer queuetransfer.add_files('/path/to/my/BIG_file.ext')# Add multiple fileslist_of_files=['/path/to/my/BIG_file_1.ext','/path/to/my/BIG_file_2.ext','/path/to/my/BIG_file_3.ext']transfer.add_files(list_of_files)# Send files to recipient(s)transfer.send(auto_complete=True)# Login to a registered Filemail accountuser=pyfilemail.User(username='user@mailprovider.com',password='YourSecretPassword2014')# List all prior transferstransfers=user.get_sent(expired=True)# Get contactsuser.get_contacts()# Get one single contactcontact=user.get_contact('contact@email.address.com')# Update that contactcontact['name']='Mr. Orange'user.update_contact(contact)# Delete contactunfriendly=user.get_contact('contact@email.address.com')user.delete_contact(unfriendly)# Download received transfers for the past 7 daystransfers=user.get_received(age=7)fortransferintransfers:transfer.download(destination='/home/myname/Downloads')# Logoutuser.logout()