files.com 1.2.102 → 1.2.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +450 -95
- package/_VERSION +1 -1
- package/docs/Errors.md +2 -0
- package/docs/models/Action.md +2 -0
- package/docs/models/ApiRequestLog.md +2 -0
- package/docs/models/History.md +2 -0
- package/docs/models/HistoryExportResult.md +2 -0
- package/docs/models/SettingsChange.md +2 -0
- package/docs/models/Site.md +2 -1
- package/lib/Errors.js +546 -522
- package/lib/Files.js +1 -1
- package/lib/models/Action.js +4 -0
- package/lib/models/ApiRequestLog.js +4 -0
- package/lib/models/History.js +4 -0
- package/lib/models/HistoryExportResult.js +4 -0
- package/lib/models/SettingsChange.js +4 -0
- package/package.json +1 -1
- package/src/Errors.js +2 -0
- package/src/Files.js +1 -1
- package/src/models/Action.js +3 -0
- package/src/models/ApiRequestLog.js +3 -0
- package/src/models/History.js +3 -0
- package/src/models/HistoryExportResult.js +3 -0
- package/src/models/SettingsChange.js +3 -0
package/README.md
CHANGED
@@ -1,23 +1,29 @@
|
|
1
1
|
# Files.com JavaScript SDK
|
2
2
|
|
3
|
-
The
|
3
|
+
The content included here should be enough to get started, but please visit our
|
4
|
+
[Developer Documentation Website](https://developers.files.com/javascript/) for the complete documentation.
|
5
|
+
|
6
|
+
## Introduction
|
4
7
|
|
8
|
+
The Files.com JavaScript SDK provides convenient access to the Files.com API from applications written in JavaScript.
|
5
9
|
|
6
|
-
|
10
|
+
### Installation
|
7
11
|
|
8
12
|
To install the package:
|
9
13
|
|
10
|
-
|
14
|
+
```shell
|
15
|
+
yarn add files.com
|
16
|
+
```
|
11
17
|
|
12
18
|
or
|
13
19
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
## Usage
|
20
|
+
```shell
|
21
|
+
npm install files.com
|
22
|
+
```
|
18
23
|
|
24
|
+
### Usage
|
19
25
|
|
20
|
-
|
26
|
+
#### Import and initialize
|
21
27
|
|
22
28
|
```js
|
23
29
|
import Files from "files.com/lib/Files.js";
|
@@ -28,8 +34,7 @@ import Files from "files.com/lib/Files.js";
|
|
28
34
|
Files.setBaseUrl("https://MY-SUBDOMAIN.files.com");
|
29
35
|
```
|
30
36
|
|
31
|
-
|
32
|
-
#### `require()` vs. `import`
|
37
|
+
##### `require()` vs. `import`
|
33
38
|
|
34
39
|
The examples provided in the documentation here use the newer ES6 `import` syntax. To
|
35
40
|
instead use the older CommonJS module syntax with `require()`, ensure that `.default`
|
@@ -43,162 +48,512 @@ const User = require("files.com/lib/models/User.js").default;
|
|
43
48
|
const { LogLevel } = require("files.com/lib/Logger.js").default;
|
44
49
|
```
|
45
50
|
|
51
|
+
<Note title="Repository">
|
52
|
+
Explore the [files-sdk-javascript](https://github.com/Files-com/files-sdk-javascript) code on GitHub.
|
53
|
+
</Note>
|
46
54
|
|
47
|
-
###
|
55
|
+
### Getting Support
|
48
56
|
|
49
|
-
|
57
|
+
The Files.com team is happy to help with any SDK Integration challenges you
|
58
|
+
may face.
|
50
59
|
|
60
|
+
Just email support@files.com and we'll get the process started.
|
51
61
|
|
52
|
-
|
62
|
+
## Authentication
|
53
63
|
|
54
|
-
|
64
|
+
### Authenticate with an API Key
|
55
65
|
|
56
|
-
|
66
|
+
Authenticating with an API key is the recommended authentication method for most scenarios, and is
|
67
|
+
the method used in the examples on this site.
|
57
68
|
|
69
|
+
To use the API or SDKs with an API Key, first generate an API key from the [web
|
70
|
+
interface](https://www.files.com/docs/sdk-and-apis/api-keys) or [via the API or an
|
71
|
+
SDK](/javascript/resources/developers/api-keys).
|
58
72
|
|
59
|
-
|
73
|
+
Note that when using a user-specific API key, if the user is an administrator, you will have full
|
74
|
+
access to the entire API. If the user is not an administrator, you will only be able to access files
|
75
|
+
that user can access, and no access will be granted to site administration functions in the API.
|
60
76
|
|
61
|
-
|
77
|
+
```javascript title="Example Request"
|
78
|
+
Files.setApiKey('YOUR_API_KEY')
|
62
79
|
|
63
|
-
|
64
|
-
|
80
|
+
// Alternatively, you can specify the API key on a per-object basis in the second parameter to a model constructor.
|
81
|
+
const user = new User(params, { apiKey: 'YOUR_API_KEY' })
|
65
82
|
|
83
|
+
// You may also specify the API key on a per-request basis in the final parameter to static methods.
|
84
|
+
await User.find(id, params, { apiKey: 'YOUR_API_KEY' })
|
85
|
+
```
|
66
86
|
|
67
|
-
|
87
|
+
<Note>
|
88
|
+
Don't forget to replace the placeholder, `YOUR_API_KEY`, with your actual API key.
|
89
|
+
</Note>
|
68
90
|
|
69
|
-
|
91
|
+
### Authenticate with a Session
|
70
92
|
|
71
|
-
|
72
|
-
|
93
|
+
You can also authenticate to the REST API or SDKs by creating a user session using the username and
|
94
|
+
password of an active user. If the user is an administrator, the session will have full access to
|
95
|
+
the entire API. Sessions created from regular user accounts will only be able to access files that
|
96
|
+
user can access, and no access will be granted to site administration functions.
|
73
97
|
|
74
|
-
|
98
|
+
API sessions use the exact same session timeout settings as web interface sessions. When an API
|
99
|
+
session times out, simply create a new session and resume where you left off. This process is not
|
100
|
+
automatically handled by SDKs because we do not want to store password information in memory without
|
101
|
+
your explicit consent.
|
75
102
|
|
76
|
-
|
103
|
+
#### Logging in
|
77
104
|
|
78
|
-
|
105
|
+
To create a session, the `create` method is called on the `Session` object with the user's username and
|
106
|
+
password.
|
79
107
|
|
80
|
-
|
81
|
-
const user = new User(params, { sessionId: session.id })
|
108
|
+
This returns a session object that can be used to authenticate SDK method calls.
|
82
109
|
|
110
|
+
```javascript title="Example Request"
|
111
|
+
const session = await Session.create({ username: 'motor', password: 'vroom' })
|
112
|
+
```
|
113
|
+
|
114
|
+
#### Using a session
|
115
|
+
|
116
|
+
Once a session has been created, you can store the session globally, use the session per object, or use the session per request to authenticate SDK operations.
|
117
|
+
|
118
|
+
```javascript title="Example Request"
|
119
|
+
// You may set the returned session ID to be used by default for subsequent requests.
|
120
|
+
Files.setSessionId(session.id)
|
83
121
|
|
84
|
-
|
122
|
+
// Alternatively, you can specify the session ID on a per-object basis in the second parameter to a model constructor.
|
123
|
+
const user = new User(params, { session_id: session.id })
|
85
124
|
|
86
|
-
You
|
125
|
+
// You may also specify the session ID on a per-request basis in the final parameter to static methods.
|
126
|
+
await User.find(id, params, { session_id: session.id })
|
127
|
+
```
|
128
|
+
|
129
|
+
#### Logging out
|
87
130
|
|
131
|
+
User sessions can be ended calling the `destroy` method on the `session` object.
|
132
|
+
|
133
|
+
```javascript title="Example Request"
|
134
|
+
await Session.destroy()
|
135
|
+
```
|
88
136
|
|
89
|
-
|
137
|
+
## Configuration
|
90
138
|
|
91
|
-
|
92
|
-
Files.setLogLevel(LogLevel.INFO)
|
139
|
+
### Configuration options
|
93
140
|
|
94
|
-
|
95
|
-
Call Files.setLogLevel() with one of the following:
|
96
|
-
LogLevel.NONE
|
97
|
-
LogLevel.ERROR
|
98
|
-
LogLevel.WARN
|
99
|
-
LogLevel.INFO (default)
|
100
|
-
LogLevel.DEBUG
|
101
|
-
*/
|
141
|
+
#### Base URL
|
102
142
|
|
143
|
+
Setting the base URL for the API is required if your site is configured to disable global acceleration.
|
144
|
+
This can also be set to use a mock server in development or CI.
|
145
|
+
|
146
|
+
```javascript title="Example setting"
|
147
|
+
Files.setBaseUrl("https://MY-SUBDOMAIN.files.com");
|
148
|
+
```
|
149
|
+
|
150
|
+
#### Log level
|
151
|
+
|
152
|
+
Supported values:
|
153
|
+
|
154
|
+
* LogLevel.NONE
|
155
|
+
* LogLevel.ERROR
|
156
|
+
* LogLevel.WARN
|
157
|
+
* LogLevel.INFO (default)
|
158
|
+
* LogLevel.DEBUG
|
159
|
+
|
160
|
+
```javascript title="Example setting"
|
161
|
+
import { LogLevel } from 'files.com/lib/Logger.js'
|
162
|
+
Files.setLogLevel(LogLevel.INFO)
|
163
|
+
```
|
103
164
|
|
104
165
|
#### Debugging
|
105
166
|
|
106
|
-
|
107
|
-
// enable debug logging of API requests (default: false)
|
108
|
-
debugRequest: false,
|
167
|
+
Enable debug logging of API requests and/or response headers. Both settings default to `false`.
|
109
168
|
|
110
|
-
|
111
|
-
|
112
|
-
|
169
|
+
```javascript title="Example setting"
|
170
|
+
Files.configureDebugging({
|
171
|
+
debugRequest: true,
|
172
|
+
debugResponseHeaders: true,
|
173
|
+
})
|
174
|
+
```
|
175
|
+
|
176
|
+
#### Network settings
|
113
177
|
|
178
|
+
```javascript title="Example setting"
|
179
|
+
Files.configureNetwork({
|
180
|
+
// max retries (default: 3)
|
181
|
+
maxNetworkRetries: 3,
|
114
182
|
|
115
|
-
|
183
|
+
// minimum delay in seconds before retrying (default: 0.5)
|
184
|
+
minNetworkRetryDelay: 0.5,
|
116
185
|
|
117
|
-
|
118
|
-
|
119
|
-
maxNetworkRetries: 3,
|
186
|
+
// max delay in seconds before retrying (default: 1.5)
|
187
|
+
maxNetworkRetryDelay: 1.5,
|
120
188
|
|
121
|
-
|
122
|
-
|
189
|
+
// network timeout in seconds (default: 30.0)
|
190
|
+
networkTimeout: 30.0,
|
123
191
|
|
124
|
-
|
125
|
-
|
192
|
+
// auto-fetch all pages when results span multiple pages (default: `true`)
|
193
|
+
autoPaginate: true,
|
194
|
+
})
|
195
|
+
```
|
126
196
|
|
127
|
-
|
128
|
-
networkTimeout: 30.0,
|
197
|
+
### Logging
|
129
198
|
|
130
|
-
|
131
|
-
autoPaginate: true,
|
132
|
-
})
|
199
|
+
The Files.com SDK is compatible with the standard log4j logging scheme.
|
133
200
|
|
201
|
+
Add `com.files` logger to your `Loggers` root in the `log4j2.xml` file.
|
134
202
|
|
135
|
-
|
203
|
+
```xml title="log4j2.xml"
|
204
|
+
<Loggers>
|
205
|
+
<!-- set preferred level -->
|
206
|
+
<Logger name="com.files" level="TRACE" />
|
207
|
+
<!-- to enable network request -->
|
208
|
+
<Logger name="okhttp3.logging.wire" level="INFO"/>
|
209
|
+
</Loggers>
|
210
|
+
```
|
136
211
|
|
212
|
+
Create a `resources/log4j2.xml` file.
|
213
|
+
|
214
|
+
```xml title="resources/log4j2.xml"
|
215
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
216
|
+
<Configuration>
|
217
|
+
<Appenders>
|
218
|
+
<Console name="Console" target="SYSTEM_OUT">
|
219
|
+
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
220
|
+
</Console>
|
221
|
+
</Appenders>
|
222
|
+
<Loggers>
|
223
|
+
<!-- set preferred level -->
|
224
|
+
<Logger name="com.files" level="TRACE"/>
|
225
|
+
<!-- to enable network request -->
|
226
|
+
<Logger name="okhttp3.logging.wire" level="INFO"/>
|
227
|
+
</Loggers>
|
228
|
+
</Configuration>
|
229
|
+
```
|
137
230
|
|
138
|
-
|
231
|
+
You can read more about [log4j2 configuration](https://logging.apache.org/log4j/2.x/manual/configuration.html).
|
139
232
|
|
140
|
-
|
141
|
-
const dirFiles = await Folder.listFor('/')
|
233
|
+
## Errors
|
142
234
|
|
235
|
+
The Files.com JavaScript SDK will return errors by raising exceptions. There are many exception classes defined in the Files SDK that correspond
|
236
|
+
to specific errors.
|
143
237
|
|
144
|
-
|
238
|
+
The raised exceptions come from two categories:
|
145
239
|
|
146
|
-
|
147
|
-
|
240
|
+
1. SDK Exceptions - errors that originate within the SDK
|
241
|
+
2. API Exceptions - errors that occur due to the response from the Files.com API. These errors are grouped into common error types.
|
148
242
|
|
149
|
-
|
150
|
-
|
243
|
+
There are several types of exceptions within each category. Exception classes indicate different types of errors and are named in a
|
244
|
+
fashion that describe the general premise of the originating error. More details can be found in the exception object message using the
|
245
|
+
`message` attribute.
|
151
246
|
|
152
|
-
|
153
|
-
|
154
|
-
|
247
|
+
Use standard Javascript exception handling to detect and deal with errors. It is generally recommended to catch specific errors first, then
|
248
|
+
catch the general `FilesError` exception as a catch-all.
|
249
|
+
|
250
|
+
```javascript title="Example Error Handling"
|
251
|
+
import Session from 'files.com/lib/models/Session.js'
|
252
|
+
import * as FilesErrors from 'files.com/lib/Errors.js'
|
253
|
+
|
254
|
+
try {
|
255
|
+
const session = await Session.create({ username: 'USERNAME', password: 'BADPASSWORD' })
|
256
|
+
}
|
257
|
+
catch(err) {
|
258
|
+
if (err instanceof FilesErrors.NotAuthenticatedError) {
|
259
|
+
console.log("Authorization Error Occured (" + err.constructor.name + "): " + err.error);
|
260
|
+
} else if (err instanceof FilesErrors.FilesError) {
|
261
|
+
console.log("Unknown Error Occured (" + err.constructor.name + "): " + err.error);
|
262
|
+
} else {
|
263
|
+
throw err;
|
155
264
|
}
|
265
|
+
}
|
266
|
+
```
|
267
|
+
|
268
|
+
### Error Types
|
269
|
+
|
270
|
+
#### SDK Errors
|
271
|
+
|
272
|
+
SDK errors are general errors that occur within the SDK code. These errors generate exceptions. Each of these
|
273
|
+
exception classes inherit from a standard `FilesError` base class.
|
274
|
+
|
275
|
+
```javascript title="Example SDK Exception Class Inheritance Structure"
|
276
|
+
import * as FilesErrors from 'files.com/lib/Errors.js'
|
277
|
+
|
278
|
+
FilesErrors.ConfigurationError ->
|
279
|
+
FilesErrors.FilesError ->
|
280
|
+
Error
|
281
|
+
```
|
282
|
+
##### SDK Exception Classes
|
156
283
|
|
284
|
+
| Exception Class Name| Description |
|
285
|
+
| --------------- | ------------ |
|
286
|
+
| `ConfigurationError`| Invalid SDK configuration parameters |
|
287
|
+
| `EmptyPropertyError`| Missing a required property |
|
288
|
+
| `InvalidParameterError`| A passed in parameter is invalid |
|
289
|
+
| `MissingParameterError`| A method parameter is missing |
|
290
|
+
| `NotImplementedError`| The called method has not be implemented by the SDK |
|
291
|
+
|
292
|
+
#### API Errors
|
293
|
+
|
294
|
+
API errors are errors returned by the Files.com API. Each exception class inherits from an error group base class.
|
295
|
+
The error group base class indicates a particular type of error.
|
296
|
+
|
297
|
+
```shell title="Example API Exception Class Inheritance Structure"
|
298
|
+
import * as FilesErrors from 'files.com/lib/Errors.js'
|
299
|
+
|
300
|
+
FilesErrors.NotAuthorized_FolderAdminPermissionRequiredError ->
|
301
|
+
FilesErrors.NotAuthorizedError ->
|
302
|
+
FilesErrors.FilesApiError ->
|
303
|
+
FilesErrors.FilesError ->
|
304
|
+
Error
|
305
|
+
```
|
306
|
+
##### API Exception Classes
|
307
|
+
|
308
|
+
| Exception Class Name | Error Group |
|
309
|
+
| --------- | --------- |
|
310
|
+
| `BadRequest_AgentUpgradeRequiredError`| `BadRequestError` |
|
311
|
+
| `BadRequest_AttachmentTooLargeError`| `BadRequestError` |
|
312
|
+
| `BadRequest_CannotDownloadDirectoryError`| `BadRequestError` |
|
313
|
+
| `BadRequest_CantMoveWithMultipleLocationsError`| `BadRequestError` |
|
314
|
+
| `BadRequest_DatetimeParseError`| `BadRequestError` |
|
315
|
+
| `BadRequest_DestinationSameError`| `BadRequestError` |
|
316
|
+
| `BadRequest_FolderMustNotBeAFileError`| `BadRequestError` |
|
317
|
+
| `BadRequest_InvalidBodyError`| `BadRequestError` |
|
318
|
+
| `BadRequest_InvalidCursorError`| `BadRequestError` |
|
319
|
+
| `BadRequest_InvalidCursorTypeForSortError`| `BadRequestError` |
|
320
|
+
| `BadRequest_InvalidEtagsError`| `BadRequestError` |
|
321
|
+
| `BadRequest_InvalidFilterAliasCombinationError`| `BadRequestError` |
|
322
|
+
| `BadRequest_InvalidFilterCombinationError`| `BadRequestError` |
|
323
|
+
| `BadRequest_InvalidFilterFieldError`| `BadRequestError` |
|
324
|
+
| `BadRequest_InvalidFilterParamError`| `BadRequestError` |
|
325
|
+
| `BadRequest_InvalidFilterParamValueError`| `BadRequestError` |
|
326
|
+
| `BadRequest_InvalidInputEncodingError`| `BadRequestError` |
|
327
|
+
| `BadRequest_InvalidInterfaceError`| `BadRequestError` |
|
328
|
+
| `BadRequest_InvalidOauthProviderError`| `BadRequestError` |
|
329
|
+
| `BadRequest_InvalidPathError`| `BadRequestError` |
|
330
|
+
| `BadRequest_InvalidReturnToUrlError`| `BadRequestError` |
|
331
|
+
| `BadRequest_InvalidUploadOffsetError`| `BadRequestError` |
|
332
|
+
| `BadRequest_InvalidUploadPartGapError`| `BadRequestError` |
|
333
|
+
| `BadRequest_InvalidUploadPartSizeError`| `BadRequestError` |
|
334
|
+
| `BadRequest_MethodNotAllowedError`| `BadRequestError` |
|
335
|
+
| `BadRequest_NoValidInputParamsError`| `BadRequestError` |
|
336
|
+
| `BadRequest_PartNumberTooLargeError`| `BadRequestError` |
|
337
|
+
| `BadRequest_PathCannotHaveTrailingWhitespaceError`| `BadRequestError` |
|
338
|
+
| `BadRequest_ReauthenticationNeededFieldsError`| `BadRequestError` |
|
339
|
+
| `BadRequest_RequestParamsContainInvalidCharacterError`| `BadRequestError` |
|
340
|
+
| `BadRequest_RequestParamsInvalidError`| `BadRequestError` |
|
341
|
+
| `BadRequest_RequestParamsRequiredError`| `BadRequestError` |
|
342
|
+
| `BadRequest_SearchAllOnChildPathError`| `BadRequestError` |
|
343
|
+
| `BadRequest_UnsupportedCurrencyError`| `BadRequestError` |
|
344
|
+
| `BadRequest_UnsupportedHttpResponseFormatError`| `BadRequestError` |
|
345
|
+
| `BadRequest_UnsupportedMediaTypeError`| `BadRequestError` |
|
346
|
+
| `BadRequest_UserIdInvalidError`| `BadRequestError` |
|
347
|
+
| `BadRequest_UserIdOnUserEndpointError`| `BadRequestError` |
|
348
|
+
| `BadRequest_UserRequiredError`| `BadRequestError` |
|
349
|
+
| `NotAuthenticated_AdditionalAuthenticationRequiredError`| `NotAuthenticatedError` |
|
350
|
+
| `NotAuthenticated_AuthenticationRequiredError`| `NotAuthenticatedError` |
|
351
|
+
| `NotAuthenticated_BundleRegistrationCodeFailedError`| `NotAuthenticatedError` |
|
352
|
+
| `NotAuthenticated_FilesAgentTokenFailedError`| `NotAuthenticatedError` |
|
353
|
+
| `NotAuthenticated_InboxRegistrationCodeFailedError`| `NotAuthenticatedError` |
|
354
|
+
| `NotAuthenticated_InvalidCredentialsError`| `NotAuthenticatedError` |
|
355
|
+
| `NotAuthenticated_InvalidOauthError`| `NotAuthenticatedError` |
|
356
|
+
| `NotAuthenticated_InvalidOrExpiredCodeError`| `NotAuthenticatedError` |
|
357
|
+
| `NotAuthenticated_InvalidSessionError`| `NotAuthenticatedError` |
|
358
|
+
| `NotAuthenticated_InvalidUsernameOrPasswordError`| `NotAuthenticatedError` |
|
359
|
+
| `NotAuthenticated_LockedOutError`| `NotAuthenticatedError` |
|
360
|
+
| `NotAuthenticated_LockoutRegionMismatchError`| `NotAuthenticatedError` |
|
361
|
+
| `NotAuthenticated_OneTimePasswordIncorrectError`| `NotAuthenticatedError` |
|
362
|
+
| `NotAuthenticated_TwoFactorAuthenticationErrorError`| `NotAuthenticatedError` |
|
363
|
+
| `NotAuthenticated_TwoFactorAuthenticationSetupExpiredError`| `NotAuthenticatedError` |
|
364
|
+
| `NotAuthorized_ApiKeyIsDisabledError`| `NotAuthorizedError` |
|
365
|
+
| `NotAuthorized_ApiKeyIsPathRestrictedError`| `NotAuthorizedError` |
|
366
|
+
| `NotAuthorized_ApiKeyOnlyForDesktopAppError`| `NotAuthorizedError` |
|
367
|
+
| `NotAuthorized_ApiKeyOnlyForMobileAppError`| `NotAuthorizedError` |
|
368
|
+
| `NotAuthorized_ApiKeyOnlyForOfficeIntegrationError`| `NotAuthorizedError` |
|
369
|
+
| `NotAuthorized_BillingPermissionRequiredError`| `NotAuthorizedError` |
|
370
|
+
| `NotAuthorized_BundleMaximumUsesReachedError`| `NotAuthorizedError` |
|
371
|
+
| `NotAuthorized_CannotLoginWhileUsingKeyError`| `NotAuthorizedError` |
|
372
|
+
| `NotAuthorized_CantActForOtherUserError`| `NotAuthorizedError` |
|
373
|
+
| `NotAuthorized_ContactAdminForPasswordChangeHelpError`| `NotAuthorizedError` |
|
374
|
+
| `NotAuthorized_FilesAgentFailedAuthorizationError`| `NotAuthorizedError` |
|
375
|
+
| `NotAuthorized_FolderAdminOrBillingPermissionRequiredError`| `NotAuthorizedError` |
|
376
|
+
| `NotAuthorized_FolderAdminPermissionRequiredError`| `NotAuthorizedError` |
|
377
|
+
| `NotAuthorized_FullPermissionRequiredError`| `NotAuthorizedError` |
|
378
|
+
| `NotAuthorized_HistoryPermissionRequiredError`| `NotAuthorizedError` |
|
379
|
+
| `NotAuthorized_InsufficientPermissionForParamsError`| `NotAuthorizedError` |
|
380
|
+
| `NotAuthorized_InsufficientPermissionForSiteError`| `NotAuthorizedError` |
|
381
|
+
| `NotAuthorized_MustAuthenticateWithApiKeyError`| `NotAuthorizedError` |
|
382
|
+
| `NotAuthorized_NeedAdminPermissionForInboxError`| `NotAuthorizedError` |
|
383
|
+
| `NotAuthorized_NonAdminsMustQueryByFolderOrPathError`| `NotAuthorizedError` |
|
384
|
+
| `NotAuthorized_NotAllowedToCreateBundleError`| `NotAuthorizedError` |
|
385
|
+
| `NotAuthorized_PasswordChangeNotRequiredError`| `NotAuthorizedError` |
|
386
|
+
| `NotAuthorized_PasswordChangeRequiredError`| `NotAuthorizedError` |
|
387
|
+
| `NotAuthorized_ReadOnlySessionError`| `NotAuthorizedError` |
|
388
|
+
| `NotAuthorized_ReadPermissionRequiredError`| `NotAuthorizedError` |
|
389
|
+
| `NotAuthorized_ReauthenticationFailedError`| `NotAuthorizedError` |
|
390
|
+
| `NotAuthorized_ReauthenticationFailedFinalError`| `NotAuthorizedError` |
|
391
|
+
| `NotAuthorized_ReauthenticationNeededActionError`| `NotAuthorizedError` |
|
392
|
+
| `NotAuthorized_RecaptchaFailedError`| `NotAuthorizedError` |
|
393
|
+
| `NotAuthorized_SelfManagedRequiredError`| `NotAuthorizedError` |
|
394
|
+
| `NotAuthorized_SiteAdminRequiredError`| `NotAuthorizedError` |
|
395
|
+
| `NotAuthorized_SiteFilesAreImmutableError`| `NotAuthorizedError` |
|
396
|
+
| `NotAuthorized_TwoFactorAuthenticationRequiredError`| `NotAuthorizedError` |
|
397
|
+
| `NotAuthorized_UserIdWithoutSiteAdminError`| `NotAuthorizedError` |
|
398
|
+
| `NotAuthorized_WriteAndBundlePermissionRequiredError`| `NotAuthorizedError` |
|
399
|
+
| `NotAuthorized_WritePermissionRequiredError`| `NotAuthorizedError` |
|
400
|
+
| `NotAuthorized_ZipDownloadIpMismatchError`| `NotAuthorizedError` |
|
401
|
+
| `NotFound_ApiKeyNotFoundError`| `NotFoundError` |
|
402
|
+
| `NotFound_BundlePathNotFoundError`| `NotFoundError` |
|
403
|
+
| `NotFound_BundleRegistrationNotFoundError`| `NotFoundError` |
|
404
|
+
| `NotFound_CodeNotFoundError`| `NotFoundError` |
|
405
|
+
| `NotFound_FileNotFoundError`| `NotFoundError` |
|
406
|
+
| `NotFound_FileUploadNotFoundError`| `NotFoundError` |
|
407
|
+
| `NotFound_FolderNotFoundError`| `NotFoundError` |
|
408
|
+
| `NotFound_GroupNotFoundError`| `NotFoundError` |
|
409
|
+
| `NotFound_InboxNotFoundError`| `NotFoundError` |
|
410
|
+
| `NotFound_NestedNotFoundError`| `NotFoundError` |
|
411
|
+
| `NotFound_PlanNotFoundError`| `NotFoundError` |
|
412
|
+
| `NotFound_SiteNotFoundError`| `NotFoundError` |
|
413
|
+
| `NotFound_UserNotFoundError`| `NotFoundError` |
|
414
|
+
| `ProcessingFailure_AlreadyCompletedError`| `ProcessingFailureError` |
|
415
|
+
| `ProcessingFailure_AutomationCannotBeRunManuallyError`| `ProcessingFailureError` |
|
416
|
+
| `ProcessingFailure_BehaviorNotAllowedOnRemoteServerError`| `ProcessingFailureError` |
|
417
|
+
| `ProcessingFailure_BundleOnlyAllowsPreviewsError`| `ProcessingFailureError` |
|
418
|
+
| `ProcessingFailure_BundleOperationRequiresSubfolderError`| `ProcessingFailureError` |
|
419
|
+
| `ProcessingFailure_CouldNotCreateParentError`| `ProcessingFailureError` |
|
420
|
+
| `ProcessingFailure_DestinationExistsError`| `ProcessingFailureError` |
|
421
|
+
| `ProcessingFailure_DestinationFolderLimitedError`| `ProcessingFailureError` |
|
422
|
+
| `ProcessingFailure_DestinationParentConflictError`| `ProcessingFailureError` |
|
423
|
+
| `ProcessingFailure_DestinationParentDoesNotExistError`| `ProcessingFailureError` |
|
424
|
+
| `ProcessingFailure_ExpiredPrivateKeyError`| `ProcessingFailureError` |
|
425
|
+
| `ProcessingFailure_ExpiredPublicKeyError`| `ProcessingFailureError` |
|
426
|
+
| `ProcessingFailure_ExportFailureError`| `ProcessingFailureError` |
|
427
|
+
| `ProcessingFailure_ExportNotReadyError`| `ProcessingFailureError` |
|
428
|
+
| `ProcessingFailure_FailedToChangePasswordError`| `ProcessingFailureError` |
|
429
|
+
| `ProcessingFailure_FileLockedError`| `ProcessingFailureError` |
|
430
|
+
| `ProcessingFailure_FileNotUploadedError`| `ProcessingFailureError` |
|
431
|
+
| `ProcessingFailure_FilePendingProcessingError`| `ProcessingFailureError` |
|
432
|
+
| `ProcessingFailure_FileProcessingErrorError`| `ProcessingFailureError` |
|
433
|
+
| `ProcessingFailure_FileTooBigToDecryptError`| `ProcessingFailureError` |
|
434
|
+
| `ProcessingFailure_FileTooBigToEncryptError`| `ProcessingFailureError` |
|
435
|
+
| `ProcessingFailure_FileUploadedToWrongRegionError`| `ProcessingFailureError` |
|
436
|
+
| `ProcessingFailure_FilenameTooLongError`| `ProcessingFailureError` |
|
437
|
+
| `ProcessingFailure_FolderLockedError`| `ProcessingFailureError` |
|
438
|
+
| `ProcessingFailure_FolderNotEmptyError`| `ProcessingFailureError` |
|
439
|
+
| `ProcessingFailure_HistoryUnavailableError`| `ProcessingFailureError` |
|
440
|
+
| `ProcessingFailure_InvalidBundleCodeError`| `ProcessingFailureError` |
|
441
|
+
| `ProcessingFailure_InvalidFileTypeError`| `ProcessingFailureError` |
|
442
|
+
| `ProcessingFailure_InvalidFilenameError`| `ProcessingFailureError` |
|
443
|
+
| `ProcessingFailure_InvalidPriorityColorError`| `ProcessingFailureError` |
|
444
|
+
| `ProcessingFailure_InvalidRangeError`| `ProcessingFailureError` |
|
445
|
+
| `ProcessingFailure_ModelSaveErrorError`| `ProcessingFailureError` |
|
446
|
+
| `ProcessingFailure_MultipleProcessingErrorsError`| `ProcessingFailureError` |
|
447
|
+
| `ProcessingFailure_PathTooLongError`| `ProcessingFailureError` |
|
448
|
+
| `ProcessingFailure_RecipientAlreadySharedError`| `ProcessingFailureError` |
|
449
|
+
| `ProcessingFailure_RemoteServerErrorError`| `ProcessingFailureError` |
|
450
|
+
| `ProcessingFailure_ResourceLockedError`| `ProcessingFailureError` |
|
451
|
+
| `ProcessingFailure_SubfolderLockedError`| `ProcessingFailureError` |
|
452
|
+
| `ProcessingFailure_TwoFactorAuthenticationCodeAlreadySentError`| `ProcessingFailureError` |
|
453
|
+
| `ProcessingFailure_TwoFactorAuthenticationCountryBlacklistedError`| `ProcessingFailureError` |
|
454
|
+
| `ProcessingFailure_TwoFactorAuthenticationGeneralErrorError`| `ProcessingFailureError` |
|
455
|
+
| `ProcessingFailure_TwoFactorAuthenticationUnsubscribedRecipientError`| `ProcessingFailureError` |
|
456
|
+
| `ProcessingFailure_UpdatesNotAllowedForRemotesError`| `ProcessingFailureError` |
|
457
|
+
| `RateLimited_DuplicateShareRecipientError`| `RateLimitedError` |
|
458
|
+
| `RateLimited_ReauthenticationRateLimitedError`| `RateLimitedError` |
|
459
|
+
| `RateLimited_TooManyConcurrentLoginsError`| `RateLimitedError` |
|
460
|
+
| `RateLimited_TooManyConcurrentRequestsError`| `RateLimitedError` |
|
461
|
+
| `RateLimited_TooManyLoginAttemptsError`| `RateLimitedError` |
|
462
|
+
| `RateLimited_TooManyRequestsError`| `RateLimitedError` |
|
463
|
+
| `RateLimited_TooManySharesError`| `RateLimitedError` |
|
464
|
+
| `ServiceUnavailable_AgentUnavailableError`| `ServiceUnavailableError` |
|
465
|
+
| `ServiceUnavailable_AutomationsUnavailableError`| `ServiceUnavailableError` |
|
466
|
+
| `ServiceUnavailable_MigrationInProgressError`| `ServiceUnavailableError` |
|
467
|
+
| `ServiceUnavailable_SiteDisabledError`| `ServiceUnavailableError` |
|
468
|
+
| `ServiceUnavailable_UploadsUnavailableError`| `ServiceUnavailableError` |
|
469
|
+
| `SiteConfiguration_AccountAlreadyExistsError`| `SiteConfigurationError` |
|
470
|
+
| `SiteConfiguration_AccountOverdueError`| `SiteConfigurationError` |
|
471
|
+
| `SiteConfiguration_NoAccountForSiteError`| `SiteConfigurationError` |
|
472
|
+
| `SiteConfiguration_SiteWasRemovedError`| `SiteConfigurationError` |
|
473
|
+
| `SiteConfiguration_TrialExpiredError`| `SiteConfigurationError` |
|
474
|
+
| `SiteConfiguration_TrialLockedError`| `SiteConfigurationError` |
|
475
|
+
| `SiteConfiguration_UserRequestsEnabledRequiredError`| `SiteConfigurationError` |
|
476
|
+
|
477
|
+
## Examples
|
478
|
+
|
479
|
+
### File Operations
|
480
|
+
|
481
|
+
#### List root folder
|
482
|
+
|
483
|
+
```javascript
|
484
|
+
import Folder from 'files.com/lib/models/Folder.js'
|
485
|
+
const dirFiles = await Folder.listFor('/')
|
486
|
+
```
|
487
|
+
|
488
|
+
#### Uploading a file
|
489
|
+
|
490
|
+
```javascript
|
491
|
+
import File from 'files.com/lib/models/File.js'
|
492
|
+
import { isBrowser } from 'files.com/lib/utils.js'
|
493
|
+
|
494
|
+
// uploading raw file data
|
495
|
+
await File.uploadData(destinationFileName, data)
|
496
|
+
|
497
|
+
// uploading a file on disk (not available in browser)
|
498
|
+
if (!isBrowser()) {
|
499
|
+
await File.uploadFile(destinationFileName, sourceFilePath)
|
500
|
+
}
|
501
|
+
```
|
157
502
|
|
158
503
|
#### Downloading a file
|
159
504
|
|
160
505
|
##### Get a downloadable file object by path
|
161
506
|
|
162
|
-
|
163
|
-
|
164
|
-
const foundFile = await File.find(remoteFilePath)
|
165
|
-
const downloadableFile = await foundFile.download()
|
507
|
+
```javascript
|
508
|
+
import File from 'files.com/lib/models/File.js'
|
166
509
|
|
510
|
+
const foundFile = await File.find(remoteFilePath)
|
511
|
+
const downloadableFile = await foundFile.download()
|
512
|
+
```
|
167
513
|
|
168
514
|
##### Download a file (not available in browser)
|
169
515
|
|
170
|
-
|
171
|
-
|
172
|
-
if (!isBrowser()) {
|
173
|
-
// download to a file on disk
|
174
|
-
await downloadableFile.downloadToFile(localFilePath)
|
516
|
+
```javascript
|
517
|
+
import { isBrowser } from 'files.com/lib/utils.js'
|
175
518
|
|
176
|
-
|
177
|
-
|
519
|
+
if (!isBrowser()) {
|
520
|
+
// download to a file on disk
|
521
|
+
await downloadableFile.downloadToFile(localFilePath)
|
178
522
|
|
179
|
-
|
180
|
-
|
181
|
-
}
|
523
|
+
// download to a writable stream
|
524
|
+
await downloadableFile.downloadToStream(stream)
|
182
525
|
|
526
|
+
// download in memory and return as a UTF-8 string
|
527
|
+
const textContent = await downloadableFile.downloadToString()
|
528
|
+
}
|
529
|
+
```
|
183
530
|
|
184
531
|
#### Comparing Case insensitive files and paths
|
185
532
|
|
186
533
|
For related documentation see [Case Sensitivity Documentation](https://www.files.com/docs/files-and-folders/file-system-semantics/case-sensitivity).
|
187
534
|
|
188
|
-
|
535
|
+
```javascript
|
536
|
+
import { pathNormalizer } from 'files.com/lib/utils.js'
|
189
537
|
|
190
|
-
|
191
|
-
|
192
|
-
|
538
|
+
if (pathNormalizer.same('Fïłèńämê.Txt', 'filename.txt')) {
|
539
|
+
// the paths are the same
|
540
|
+
}
|
541
|
+
```
|
193
542
|
|
543
|
+
## Mock Server
|
194
544
|
|
195
|
-
|
545
|
+
Files.com publishes a Files.com API server, which is useful for testing your use of the Files.com
|
546
|
+
SDKs and other direct integrations against the Files.com API in an integration test environment.
|
196
547
|
|
197
|
-
|
548
|
+
It is a Ruby app that operates as a minimal server for the purpose of testing basic network
|
549
|
+
operations and JSON encoding for your SDK or API client. It does not maintain state and it does not
|
550
|
+
deeply inspect your submissions for correctness.
|
198
551
|
|
552
|
+
Eventually we will add more features intended for integration testing, such as the ability to
|
553
|
+
intentionally provoke errors.
|
199
554
|
|
200
|
-
|
555
|
+
Download the server as a Docker image via [Docker Hub](https://hub.docker.com/r/filescom/files-mock-server).
|
201
556
|
|
202
|
-
The
|
557
|
+
The Source Code is also available on [GitHub](https://github.com/Files-com/files-mock-server).
|
203
558
|
|
204
|
-
|
559
|
+
A README is available on the GitHub link.
|
package/_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.104
|
package/docs/Errors.md
CHANGED
@@ -94,6 +94,7 @@ These errors are derived from the error groups listed above.
|
|
94
94
|
### NotAuthenticated_InvalidCredentialsError
|
95
95
|
### NotAuthenticated_InvalidOauthError
|
96
96
|
### NotAuthenticated_InvalidOrExpiredCodeError
|
97
|
+
### NotAuthenticated_InvalidSessionError
|
97
98
|
### NotAuthenticated_InvalidUsernameOrPasswordError
|
98
99
|
### NotAuthenticated_LockedOutError
|
99
100
|
### NotAuthenticated_LockoutRegionMismatchError
|
@@ -116,6 +117,7 @@ These errors are derived from the error groups listed above.
|
|
116
117
|
### NotAuthorized_FullPermissionRequiredError
|
117
118
|
### NotAuthorized_HistoryPermissionRequiredError
|
118
119
|
### NotAuthorized_InsufficientPermissionForParamsError
|
120
|
+
### NotAuthorized_InsufficientPermissionForSiteError
|
119
121
|
### NotAuthorized_MustAuthenticateWithApiKeyError
|
120
122
|
### NotAuthorized_NeedAdminPermissionForInboxError
|
121
123
|
### NotAuthorized_NonAdminsMustQueryByFolderOrPathError
|