# 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.617.tar.gz (81个子文件)
Files.com-1.0.617
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 4KB
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
sync_job.py 2KB
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
共 81 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 通信仿真,mseed-process-master.zip
- python,python-scheduling.rar
- python,python-quantum.rar
- python,python-project-euler.rar
- Linux常用命令及用法说明
- 基于Matlab的FFT频谱分析及IIR数字滤波器设计
- AutoCAD高压低压电气开关柜设备接线图图纸
- AutoCAD电气图纸建筑电气开关柜常用cad图纸
- 使用ASP.NET Core和Entity Framework Core来构建一个基本的进销存系统.rar
- 深度学习经典数据集+FER2013面部表情识别+附带使用方法的python代码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功