# Files.com Python Client
The Files.com Python client library provides convenient access to the Files.com API from applications written in the Python language.
## Installation
To install the package:
pip3 install Files.com
### Requirements
* Python 3.5+
* requests
## Usage
import files_sdk
### Authentication
There are multiple ways to authenticate to the API.
#### Global API Key
You can set an API key globally, like this:
files_sdk.set_api_key("my-key")
#### Per-Request API Key
Or, you can pass an API key per-request, in the Options dictionary at the end
of every method. Like this:
files_sdk.group.list({}, {"api_key": "my-key"})
That key will automatically be used for any followup actions that occur
on models returned from the API.
#### User Session
Or, you can open a user session by calling `files_sdk.session.create`
session = files_sdk.session.create({"username": "uname", "password": "pwd"})
Then use it as follows:
files_sdk.group.list({}, {"session": session})
Or use if for all subsequent API calls globally like this:
session = files_sdk.session.create({"username": "uname", "password": "pwd"})
files_sdk.set_session(session)
### Setting Global Options
You can set the following global options directly on the `files_sdk` module:
* `files_sdk.open_timeout` - open timeout in seconds (default: 30)
* `files_sdk.read_timeout` - read timeout in seconds (default: 80)
* `files_sdk.initial_network_retry_delay` - initial retry delay in seconds (default: 0.5)
* `files_sdk.max_network_retries` - max retries (default: 3)
* `files_sdk.max_network_retry_delay` - max retry delay in seconds (default: 2)
* `files_sdk.base_url` - to point this client at an on-premise
installation of Files.com, set its URL here.
* `files_sdk.console_log_level` - set to `None`, `info`, or `debug`, this enables printing
of messages to stderr in addition to normal logging
#### Log Level
This SDK utilizes the standard Python logging framework. It will respect the global log level
and you can set the module specific log level and other logging settings by getting the logger
object in the standard manner as shown below:
import logging
logging.getLogger("files_sdk")
### File Operations
This SDK allows both file based transfer and data based transfer. Please see the examples below.
#### File Download
The second parameter is optional and will simply use the remote filename by default.
files_sdk.file.download_file("/remote.txt", "local.txt")
#### File Upload
The second parameter is optional and will simply use the local filename by default.
files_sdk.file.upload_file("local.txt", "/remote.txt")
#### List root folder
for f in files_sdk.folder.list_for("/").auto_paging_iter():
print(f.type, f.path)
#### Writing a file example (string)
with files_sdk.file.open("foo.txt", 'wb') as f:
f.write("contents")
#### Writing a file example (binary)
with files_sdk.file.open("foo.txt", 'wb') as f:
f.write(b"contents")
#### Reading a file example (string)
with files_sdk.open("foo.txt", 'r') as f:
print(f.read())
#### Reading a file example (binary)
with files_sdk.open("foo.txt", 'rb') as f:
print(f.read())
### List Responses and Cursor Paging
List responses for APIs with cursor support will return an iterable object
which contains a single page of records. It has a built-in `auto_paging_iter`
method to iterate through the pages, making the additional API calls
as needed.
#### Iterating with with auto_paging_iter
list_obj = files_sdk.folder.list_for('/')
for f in list_obj.auto_paging_iter():
print(f.type, f.path)
#### Iterating manually
list_obj = files_sdk.folder.list_for('/')
for f in list_obj:
print(f.type, f.path)
while list_obj.has_next_page:
list_obj.load_next_page()
for f in list_obj:
print(f.type, f.path)
### Additional Object Documentation
Additional docs are available at https://developers.files.com/ and also
in the `docs/` subdirectory of this directory.
### Pydoc Generated Documentation coming in the future
We hope to add Pydoc documentation to a future release.
## Getting Support
The Files.com team is happy to help with any SDK Integration challenges you
may face.
Just email support@files.com and we'll get the process started.
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Files.com-1.0.529.tar.gz (80个子文件)
Files.com-1.0.529
setup.py 474B
files_sdk
__init__.py 7KB
models
errors.py 1007B
user_request.py 5KB
public_key.py 8KB
form_field_set.py 8KB
style.py 5KB
bundle_download.py 3KB
clickwrap.py 10KB
automation.py 22KB
usage_daily_snapshot.py 4KB
bundle_registration.py 3KB
invoice.py 3KB
webhook_test.py 3KB
user.py 41KB
__init__.py 3KB
history_export_result.py 5KB
external_event.py 5KB
request.py 8KB
message_comment.py 8KB
session.py 5KB
ip_address.py 3KB
as2_key.py 8KB
payment.py 3KB
inbox_upload.py 2KB
behavior.py 16KB
file_upload_part.py 2KB
bundle_recipient.py 7KB
inbox_recipient.py 7KB
api_key.py 15KB
file_comment.py 6KB
inbox_registration.py 3KB
action.py 2KB
file_action.py 8KB
invoice_line_item.py 2KB
image.py 958B
usage_snapshot.py 3KB
account_line_item.py 2KB
sso_strategy.py 6KB
payment_line_item.py 1KB
remote_server.py 36KB
history_export.py 13KB
bandwidth_snapshot.py 5KB
notification.py 13KB
lock.py 6KB
settings_change.py 4KB
message_comment_reaction.py 6KB
form_field.py 1KB
user_cipher_use.py 3KB
project.py 7KB
preview.py 1KB
dns_record.py 2KB
status.py 1KB
site.py 29KB
folder.py 6KB
public_ip_address.py 1KB
file_comment_reaction.py 4KB
bundle.py 20KB
file.py 19KB
message_reaction.py 6KB
app.py 5KB
group_user.py 9KB
permission.py 8KB
history.py 14KB
auto.py 898B
group.py 11KB
message.py 9KB
api.py 1KB
util.py 957B
list_obj.py 1KB
exceptions.py 1KB
api_client.py 9KB
setup.cfg 38B
README.md 4KB
PKG-INFO 234B
Files.com.egg-info
top_level.txt 10B
SOURCES.txt 2KB
PKG-INFO 234B
dependency_links.txt 1B
requires.txt 43B
共 80 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功