files.com / files-php-sdk
Files.com PHP SDK
Installs: 11 694
Dependents: 0
Suggesters: 0
Security: 0
Stars: 13
Watchers: 8
Forks: 3
Open Issues: 0
Requires
- php: >=5.5.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7
- psr/log: ^1.1
- dev-master
- v1.0.253
- v1.0.252
- v1.0.251
- v1.0.250
- v1.0.249
- v1.0.248
- v1.0.247
- v1.0.246
- v1.0.245
- v1.0.244
- v1.0.243
- v1.0.242
- v1.0.241
- v1.0.240
- v1.0.239
- v1.0.238
- v1.0.237
- v1.0.236
- v1.0.235
- v1.0.234
- v1.0.233
- v1.0.232
- v1.0.231
- v1.0.230
- v1.0.229
- v1.0.228
- v1.0.227
- v1.0.226
- v1.0.225
- v1.0.224
- v1.0.223
- v1.0.222
- v1.0.221
- v1.0.220
- v1.0.219
- v1.0.218
- v1.0.217
- v1.0.216
- v1.0.215
- v1.0.214
- v1.0.213
- v1.0.212
- v1.0.211
- v1.0.210
- v1.0.209
- v1.0.208
- v1.0.207
- v1.0.206
- v1.0.205
- v1.0.204
- v1.0.203
- v1.0.202
- v1.0.201
- v1.0.200
- v1.0.199
- v1.0.198
- v1.0.197
- v1.0.196
- v1.0.195
- v1.0.194
- v1.0.193
- v1.0.192
- v1.0.191
- v1.0.190
- v1.0.189
- v1.0.188
- v1.0.187
- v1.0.186
- v1.0.185
- v1.0.184
- v1.0.183
- v1.0.182
- v1.0.181
- v1.0.180
- v1.0.179
- v1.0.178
- v1.0.177
- v1.0.176
- v1.0.175
- v1.0.174
- v1.0.173
- v1.0.172
- v1.0.171
- v1.0.170
- v1.0.169
- v1.0.168
- v1.0.167
- v1.0.166
- v1.0.165
- v1.0.164
- v1.0.163
- v1.0.162
- v1.0.161
- v1.0.160
- v1.0.159
- v1.0.158
- v1.0.157
- v1.0.156
- v1.0.155
- v1.0.154
- v1.0.153
- v1.0.152
- v1.0.151
- v1.0.150
- v1.0.149
- v1.0.148
- v1.0.147
- v1.0.146
- v1.0.145
- v1.0.144
- v1.0.143
- v1.0.142
- v1.0.141
- v1.0.140
- v1.0.139
- v1.0.138
- v1.0.137
- v1.0.136
- v1.0.135
- v1.0.134
- v1.0.133
- v1.0.132
- v1.0.131
- v1.0.130
- v1.0.129
- v1.0.128
- v1.0.127
- v1.0.126
- v1.0.125
- v1.0.124
- v1.0.123
- v1.0.122
- v1.0.121
- v1.0.120
- v1.0.119
- v1.0.118
- v1.0.117
- v1.0.116
- v1.0.115
- v1.0.114
- v1.0.113
- v1.0.112
- v1.0.111
- v1.0.110
- v1.0.109
- v1.0.108
- v1.0.107
- v1.0.106
- v1.0.105
- v1.0.104
- v1.0.103
- v1.0.102
- v1.0.101
- v1.0.100
- v1.0.99
- v1.0.98
- v1.0.97
- v1.0.96
- v1.0.95
- v1.0.94
- v1.0.93
- v1.0.92
- v1.0.91
- v1.0.90
- v1.0.89
- v1.0.88
- v1.0.87
- v1.0.86
- v1.0.85
- v1.0.84
- v1.0.83
- v1.0.82
- v1.0.81
- v1.0.80
- v1.0.79
- v1.0.78
- v1.0.77
- v1.0.76
- v1.0.75
- v1.0.74
- v1.0.73
- v1.0.72
- v1.0.71
- v1.0.70
- v1.0.69
- v1.0.68
- v1.0.67
- v1.0.66
- v1.0.65
- v1.0.64
- v1.0.63
- v1.0.62
- v1.0.61
- v1.0.60
- v1.0.59
- v1.0.58
- v1.0.57
- v1.0.56
- v1.0.55
- v1.0.54
- v1.0.53
- v1.0.52
- v1.0.51
- v1.0.50
- v1.0.49
- v1.0.48
- v1.0.47
- v1.0.46
- v1.0.45
- v1.0.44
- v1.0.43
- v1.0.42
- v1.0.41
- v1.0.40
- v1.0.39
- v1.0.38
- v1.0.37
- v1.0.36
- v1.0.35
- v1.0.34
- v1.0.33
- v1.0.32
- v1.0.31
- v1.0.30
- v1.0.29
- v1.0.28
- v1.0.27
- v1.0.26
- v1.0.25
- v1.0.24
- v1.0.23
- v1.0.22
- v1.0.21
- v1.0.20
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
This package is auto-updated.
Last update: 2023-02-06 03:22:34 UTC
README
The Files.com PHP SDK provides convenient Files.com API access to applications written in PHP.
Installation
Install Composer. See https://packagist.org for more info.
If composer.phar
is already available, skip this step.
curl -sS https://getcomposer.org/installer | php
Install the SDK
php composer.phar require files.com/files-php-sdk
Requirements
- PHP 5.5+
- php-curl extension
Usage
Import and initialize
require 'vendor/autoload.php';
// set your subdomain or custom domain
\Files\Files::setBaseUrl('https://MY-SUBDOMAIN.files.com');
Authentication
There are multiple ways to authenticate to the API.
Global API Key
You can set an API key globally like this:
\Files\Files::setApiKey('my-api-key');
Per-Request API Key
Or, you can pass an API key per-request, in the options array at the end of every method like this:
$user = new \Files\Model\User($params, array('api_key' => 'my-api-key'));
User Session
Or, you can open a user session by calling \Files\Model\Session::create()
$session = \Files\Model\Session::create(['username' => $username, 'password' => $password]);
Then use it globally for all subsequent API calls like this:
\Files\Files::setSessionId($session->id);
Or, you can pass the session ID per-request, in the options array at the end of every method like this:
$user = new \Files\Model\User($params, array('session_id' => $session->id));
Session example
$session = \Files\Model\Session::create(['username' => $myUsername, 'password' => $myPassword]);
\Files\Files::setSessionId($session->id);
// do something
\Files\Model\ApiKey::list(['user_id' => 0]);
// clean up when done
\Files\Model\Session::destroy();
\Files\Files::setSessionId(null);
Setting Global Options
You can set the following global properties directly on the \Files\Files
class:
\Files\Files::$logLevel
- set to one of the following:\Files\LogLevel::NONE
\Files\LogLevel::ERROR
\Files\LogLevel::WARN
\Files\LogLevel::INFO
(default)\Files\LogLevel::DEBUG
\Files\Files::$debugRequest
- enable debug logging of API requests (default:false
)\Files\Files::$debugResponseHeaders
- enable debug logging of API response headers (default:false
)\Files\Files::$connectTimeout
- network connect timeout in seconds (default:30.0
)\Files\Files::$readTimeout
- network read timeout in seconds (default:90.0
)\Files\Files::$maxNetworkRetries
- max retries (default:3
)\Files\Files::$minNetworkRetryDelay
- minimum delay in seconds before retrying (default:0.5
)\Files\Files::$maxNetworkRetryDelay
- max delay in seconds before retrying (default:1.5
)\Files\Files::$autoPaginate
- auto-fetch all pages when results span multiple pages (default:true
)
Static File Operations
List files in root folder
$rootFiles = \Files\Model\Folder::listFor('/');
Uploading a file on disk
\Files\Model\File::uploadFile($destinationFileName, $sourceFilePath);
Uploading raw file data
\Files\Model\File::uploadData($destinationFileName, $fileData);
Download a file to stream
\Files\Model\File::downloadToStream($remoteFilePath, $outputStream);
Download a file to disk
// download entire file - with retries enabled
\Files\Model\File::downloadToFile($remoteFilePath, $localFilePath);
// partially download - just the first KB
\Files\Model\File::partialDownloadToFile($remoteFilePath, $localFilePath, 0, 1023);
// resume an incomplete download
\Files\Model\File::resumeDownloadToFile($remoteFilePath, $localFilePath);
Getting a file record by path
$foundFile = \Files\Model\File::find($remoteFilePath);
File Object Operations
Getting a file record by path
$file = new \Files\Model\File();
$file->get($remoteFilePath);
Updating metadata
$file->update([
'provided_mtime' => '2000-01-01T01:00:00Z',
'priority_color' => 'red',
]);
Retrieving metadata
$file->metadata([
'with_previews' => true,
'with_priority_color' => true,
]);
Additional Documentation
Additional docs are available at https://developers.files.com
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.