files.com 1.2.181 → 1.2.182
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 +0 -115
- package/_VERSION +1 -1
- package/lib/Files.js +1 -1
- package/package.json +1 -1
- package/src/Files.js +1 -1
package/README.md
CHANGED
|
@@ -564,121 +564,6 @@ if (pathNormalizer.same('Fïłèńämê.Txt', 'filename.txt')) {
|
|
|
564
564
|
}
|
|
565
565
|
```
|
|
566
566
|
|
|
567
|
-
## Examples
|
|
568
|
-
|
|
569
|
-
### Upload
|
|
570
|
-
|
|
571
|
-
#### Upload a File
|
|
572
|
-
|
|
573
|
-
```javascript
|
|
574
|
-
import File from 'files.com/lib/models/File.js';
|
|
575
|
-
import { isBrowser } from 'files.com/lib/utils.js';
|
|
576
|
-
|
|
577
|
-
// uploading raw file data
|
|
578
|
-
await File.uploadData(destinationFileName, data);
|
|
579
|
-
|
|
580
|
-
// upload readable stream
|
|
581
|
-
await File.uploadStream(destinationFileName, readableStream)
|
|
582
|
-
|
|
583
|
-
// uploading a file on disk (not available in browser)
|
|
584
|
-
if (!isBrowser()) {
|
|
585
|
-
await File.uploadFile(destinationFileName, sourceFilePath);
|
|
586
|
-
}
|
|
587
|
-
```
|
|
588
|
-
|
|
589
|
-
#### Create a Folder
|
|
590
|
-
|
|
591
|
-
```javascript
|
|
592
|
-
import Folder from 'files.com/lib/models/Folder.js';
|
|
593
|
-
|
|
594
|
-
await Folder.create('path/to/folder/to/be/created', {
|
|
595
|
-
mkdir_parents: true,
|
|
596
|
-
});
|
|
597
|
-
```
|
|
598
|
-
|
|
599
|
-
### Download
|
|
600
|
-
|
|
601
|
-
#### Get a Downloadable File Object by Path
|
|
602
|
-
|
|
603
|
-
```javascript
|
|
604
|
-
import File from 'files.com/lib/models/File.js';
|
|
605
|
-
|
|
606
|
-
const foundFile = await File.find(remoteFilePath);
|
|
607
|
-
const downloadableFile = await foundFile.download();
|
|
608
|
-
```
|
|
609
|
-
|
|
610
|
-
#### Download a File (not available in browser)
|
|
611
|
-
|
|
612
|
-
```javascript
|
|
613
|
-
import { isBrowser } from 'files.com/lib/utils.js';
|
|
614
|
-
|
|
615
|
-
if (!isBrowser()) {
|
|
616
|
-
// download to a file on disk
|
|
617
|
-
await downloadableFile.downloadToFile(localFilePath);
|
|
618
|
-
|
|
619
|
-
// download to a writable stream
|
|
620
|
-
await downloadableFile.downloadToStream(stream);
|
|
621
|
-
|
|
622
|
-
// download in memory and return as a UTF-8 string
|
|
623
|
-
const textContent = await downloadableFile.downloadToString();
|
|
624
|
-
}
|
|
625
|
-
```
|
|
626
|
-
|
|
627
|
-
### List
|
|
628
|
-
|
|
629
|
-
#### List Folder Contents
|
|
630
|
-
|
|
631
|
-
```javascript
|
|
632
|
-
import Folder from 'files.com/lib/models/Folder.js';
|
|
633
|
-
|
|
634
|
-
const items = await Folder.listFor('remote/path/to/folder/');
|
|
635
|
-
for (const item of items) {
|
|
636
|
-
console.log(item.path);
|
|
637
|
-
}
|
|
638
|
-
```
|
|
639
|
-
|
|
640
|
-
### Copy
|
|
641
|
-
|
|
642
|
-
The copy method works for both files and folders.
|
|
643
|
-
|
|
644
|
-
```javascript
|
|
645
|
-
import File from 'files.com/lib/models/File.js';
|
|
646
|
-
|
|
647
|
-
const file = new File({ path: 'source/path' });
|
|
648
|
-
await file.copy({ destination: 'destination/path' });
|
|
649
|
-
```
|
|
650
|
-
|
|
651
|
-
### Move
|
|
652
|
-
|
|
653
|
-
The move method works for both files and folders.
|
|
654
|
-
|
|
655
|
-
```javascript
|
|
656
|
-
import File from 'files.com/lib/models/File.js';
|
|
657
|
-
|
|
658
|
-
const file = new File({ path: 'source/path' });
|
|
659
|
-
await file.move({ destination: 'destination/path' });
|
|
660
|
-
```
|
|
661
|
-
|
|
662
|
-
### Delete
|
|
663
|
-
|
|
664
|
-
The delete method works for both files and folders.
|
|
665
|
-
|
|
666
|
-
```javascript
|
|
667
|
-
import File from 'files.com/lib/models/File.js';
|
|
668
|
-
|
|
669
|
-
const file = new File({ path: 'path/to/file/or/folder' });
|
|
670
|
-
await file.delete();
|
|
671
|
-
```
|
|
672
|
-
|
|
673
|
-
In case the folder is not empty, you can use the `recursive` argument:
|
|
674
|
-
|
|
675
|
-
```javascript
|
|
676
|
-
import File from 'files.com/lib/models/File.js';
|
|
677
|
-
|
|
678
|
-
const folder = new File({ path: 'path/to/folder' });
|
|
679
|
-
await folder.delete({ recursive: true });
|
|
680
|
-
```
|
|
681
|
-
|
|
682
567
|
## Mock Server
|
|
683
568
|
|
|
684
569
|
Files.com publishes a Files.com API server, which is useful for testing your use of the Files.com
|
package/_VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.2.
|
|
1
|
+
1.2.182
|
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.
|
|
14
|
+
var version = '1.2.182';
|
|
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
package/src/Files.js
CHANGED