files.com 1.2.103 → 1.2.104

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,23 +1,29 @@
1
1
  # Files.com JavaScript SDK
2
2
 
3
- The Files.com JavaScript SDK provides convenient access to the Files.com API from applications written in JavaScript.
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
- ## Installation
10
+ ### Installation
7
11
 
8
12
  To install the package:
9
13
 
10
- yarn add files.com
14
+ ```shell
15
+ yarn add files.com
16
+ ```
11
17
 
12
18
  or
13
19
 
14
- npm install files.com
15
-
16
-
17
- ## Usage
20
+ ```shell
21
+ npm install files.com
22
+ ```
18
23
 
24
+ ### Usage
19
25
 
20
- ### Import and initialize
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
- ### Authentication
55
+ ### Getting Support
48
56
 
49
- There are multiple ways to authenticate to the Files.com SDK for Javascript.
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
- #### Global API Key
62
+ ## Authentication
53
63
 
54
- You can set an API key globally like this:
64
+ ### Authenticate with an API Key
55
65
 
56
- Files.setApiKey('my-api-key')
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
- #### Per-Request API Key
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
- Or, you can pass an API key per-request, in the options object at the end of every method like this:
77
+ ```javascript title="Example Request"
78
+ Files.setApiKey('YOUR_API_KEY')
62
79
 
63
- import User from 'files.com/lib/models/User.js'
64
- const user = new User(params, { apiKey: 'my-api-key' })
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
- #### User Session
87
+ <Note>
88
+ Don't forget to replace the placeholder, `YOUR_API_KEY`, with your actual API key.
89
+ </Note>
68
90
 
69
- Or, you can open a user session by calling `Session.create()`
91
+ ### Authenticate with a Session
70
92
 
71
- import Session from 'files.com/lib/models/Session.js'
72
- const session = await Session.create({ username, password })
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
- Then use it globally for all subsequent API calls like this:
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
- Files.setSessionId(session.id)
103
+ #### Logging in
77
104
 
78
- Or, you can pass the session ID per-request, in the options array at the end of every method like this:
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
- import User from 'files.com/lib/models/User.js'
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
- ### Setting Global Options
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 can set the following global properties using static methods on the `Files` class:
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
- #### Log Level
137
+ ## Configuration
90
138
 
91
- import { LogLevel } from 'files.com/lib/Logger.js'
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
- Files.configureDebugging({
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
- // enable debug logging of API response headers (default: false)
111
- debugResponseHeaders: false,
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
- #### Network
183
+ // minimum delay in seconds before retrying (default: 0.5)
184
+ minNetworkRetryDelay: 0.5,
116
185
 
117
- Files.configureNetwork({
118
- // max retries (default: 3)
119
- maxNetworkRetries: 3,
186
+ // max delay in seconds before retrying (default: 1.5)
187
+ maxNetworkRetryDelay: 1.5,
120
188
 
121
- // minimum delay in seconds before retrying (default: 0.5)
122
- minNetworkRetryDelay: 0.5,
189
+ // network timeout in seconds (default: 30.0)
190
+ networkTimeout: 30.0,
123
191
 
124
- // max delay in seconds before retrying (default: 1.5)
125
- maxNetworkRetryDelay: 1.5,
192
+ // auto-fetch all pages when results span multiple pages (default: `true`)
193
+ autoPaginate: true,
194
+ })
195
+ ```
126
196
 
127
- // network timeout in seconds (default: 30.0)
128
- networkTimeout: 30.0,
197
+ ### Logging
129
198
 
130
- // auto-fetch all pages when results span multiple pages (default: `true`)
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
- ### File Operations
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
- #### List root folder
231
+ You can read more about [log4j2 configuration](https://logging.apache.org/log4j/2.x/manual/configuration.html).
139
232
 
140
- import Folder from 'files.com/lib/models/Folder.js'
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
- #### Uploading a file
238
+ The raised exceptions come from two categories:
145
239
 
146
- import File from 'files.com/lib/models/File.js'
147
- import { isBrowser } from 'files.com/lib/utils.js'
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
- // uploading raw file data
150
- await File.uploadData(destinationFileName, data)
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
- // uploading a file on disk (not available in browser)
153
- if (!isBrowser()) {
154
- await File.uploadFile(destinationFileName, sourceFilePath)
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
- import File from 'files.com/lib/models/File.js'
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
- import { isBrowser } from 'files.com/lib/utils.js'
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
- // download to a writable stream
177
- await downloadableFile.downloadToStream(stream)
519
+ if (!isBrowser()) {
520
+ // download to a file on disk
521
+ await downloadableFile.downloadToFile(localFilePath)
178
522
 
179
- // download in memory and return as a UTF-8 string
180
- const textContent = await downloadableFile.downloadToString()
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
- import { pathNormalizer } from 'files.com/lib/utils.js'
535
+ ```javascript
536
+ import { pathNormalizer } from 'files.com/lib/utils.js'
189
537
 
190
- if (pathNormalizer.same('Fïłèńämê.Txt', 'filename.txt')) {
191
- // the paths are the same
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
- ### Additional Object Documentation
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
- Additional docs are available at <https://developers.files.com>
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
- ## Getting Support
555
+ Download the server as a Docker image via [Docker Hub](https://hub.docker.com/r/filescom/files-mock-server).
201
556
 
202
- The Files.com team is happy to help with any SDK Integration challenges you may face.
557
+ The Source Code is also available on [GitHub](https://github.com/Files-com/files-mock-server).
203
558
 
204
- Just email <support@files.com> and we'll get the process started.
559
+ A README is available on the GitHub link.
package/_VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.103
1
+ 1.2.104
package/lib/Files.js CHANGED
@@ -11,7 +11,7 @@ var endpointPrefix = '/api/rest/v1';
11
11
  var apiKey;
12
12
  var baseUrl = 'https://app.files.com';
13
13
  var sessionId = null;
14
- var version = '1.2.103';
14
+ var version = '1.2.104';
15
15
  var userAgent = "Files.com JavaScript SDK v".concat(version);
16
16
  var logLevel = _Logger.LogLevel.INFO;
17
17
  var debugRequest = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "files.com",
3
- "version": "1.2.103",
3
+ "version": "1.2.104",
4
4
  "description": "Files.com SDK for JavaScript",
5
5
  "keywords": [
6
6
  "files.com",
package/src/Files.js CHANGED
@@ -5,7 +5,7 @@ const endpointPrefix = '/api/rest/v1'
5
5
  let apiKey
6
6
  let baseUrl = 'https://app.files.com'
7
7
  let sessionId = null
8
- const version = '1.2.103'
8
+ const version = '1.2.104'
9
9
  let userAgent = `Files.com JavaScript SDK v${version}`
10
10
 
11
11
  let logLevel = LogLevel.INFO