# 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.
没有合适的资源?快使用搜索试试~ 我知道了~
PyPI 官网下载 | Files.com-1.0.580.tar.gz
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 75 浏览量
2022-01-11
08:18:16
上传
评论
收藏 53KB GZ 举报
温馨提示
共80个文件
py:72个
txt:4个
pkg-info:2个
资源来自pypi官网。 资源全名:Files.com-1.0.580.tar.gz
资源推荐
资源详情
资源评论
收起资源包目录
Files.com-1.0.580.tar.gz (80个子文件)
Files.com-1.0.580
PKG-INFO 234B
files_sdk
models
ip_address.py 3KB
usage_snapshot.py 3KB
app.py 5KB
user_request.py 5KB
invoice_line_item.py 2KB
message_comment.py 8KB
as2_key.py 8KB
form_field_set.py 8KB
file_comment.py 6KB
inbox_registration.py 3KB
auto.py 898B
dns_record.py 2KB
message.py 9KB
external_event.py 5KB
user.py 41KB
project.py 7KB
history_export_result.py 5KB
action.py 2KB
lock.py 6KB
file_upload_part.py 2KB
settings_change.py 4KB
site.py 29KB
request.py 8KB
inbox_recipient.py 7KB
errors.py 1007B
bundle_recipient.py 7KB
automation.py 22KB
public_key.py 8KB
file_comment_reaction.py 4KB
user_cipher_use.py 3KB
clickwrap.py 10KB
bundle_download.py 5KB
permission.py 8KB
group.py 11KB
__init__.py 3KB
history_export.py 13KB
behavior.py 16KB
preview.py 1KB
message_reaction.py 6KB
file.py 19KB
file_action.py 8KB
payment.py 3KB
invoice.py 3KB
status.py 1KB
webhook_test.py 3KB
image.py 958B
group_user.py 9KB
notification.py 13KB
folder.py 6KB
message_comment_reaction.py 6KB
sso_strategy.py 6KB
form_field.py 1KB
bundle.py 20KB
usage_daily_snapshot.py 4KB
payment_line_item.py 1KB
api_key.py 15KB
inbox_upload.py 5KB
account_line_item.py 2KB
bundle_registration.py 3KB
style.py 5KB
history.py 14KB
bandwidth_snapshot.py 5KB
public_ip_address.py 1KB
remote_server.py 36KB
session.py 5KB
util.py 957B
__init__.py 7KB
api_client.py 9KB
api.py 1KB
list_obj.py 1KB
exceptions.py 1KB
Files.com.egg-info
PKG-INFO 234B
requires.txt 43B
SOURCES.txt 2KB
top_level.txt 10B
dependency_links.txt 1B
setup.cfg 38B
setup.py 474B
README.md 4KB
共 80 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功