# 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.
挣扎的蓝藻
- 粉丝: 14w+
- 资源: 15万+
最新资源
- 手套缺陷检测,可识别大缺陷,中等缺陷,小缺陷,使用yolo v8格式标注
- 手套缺陷检测,可识别大缺陷,中等缺陷,小缺陷,使用yolo v5格式标注
- 手套缺陷检测,可识别大缺陷,中等缺陷,小缺陷,使用yolo v9格式标注
- 手套缺陷检测,可识别大缺陷,中等缺陷,小缺陷,使用yolo v11格式标注
- KingSCADA初级培训教材3.51之第六章报警与事件
- 基于Matlab与FPGA的混频sin信号的FFT验证 分别在Matlab和FPGA开发环境上实现相同的FFT功能设计 Matlab平台开发,使用自带的fft函数与相关操作函数,绘制出混频sin信号
- 从零起步用SPSS解码医学统计.zip
- ANPC同步机(VSG)并网(参数自适应控制),基于ANPC型三电平逆变器的参数自适应控制,采用电压电流双闭环控制,中点电位平衡控制,且实现VSG并网 1.VSG参数自适应 2.VSG并网 3.提供
- TIB-js-studiocomm-6.18.1-macosx-x86-64旧版本,官网已无法找到,稀缺资源
- Pytorch实现基于BERT+ BiLSTM+CRF的命名实体识别项目(源码+数据集+运行说明)
- Serial Studio 3.0.6 Windows
- QQScreenShot.zip
- 圆周磨削抛光设备sw18全套技术资料100%好用.zip
- DCDC电路,模拟ic设计,集成电路设计,tsmc0.18um工艺,正向设计,PWM+PFM混合调制 有比较详细的设计仿真报告,重载PWM,轻载PFM 输入电压1.6-1.8V,输出电压0.4-1
- 基于C++和QT的ATM机三级项目
- 成熟的VCU应用层模型 包含接口定义 可编译 实车量产 成熟的VCU应用层模型 应用层建模学习,可通过成熟的模型, 借鉴逻辑处理和算法. 除整体模型外,每个功能有单独的模型, 包含接口定义,支持编译
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈