b2-cloud-storage 1.0.2 → 1.0.5
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 +54 -55
- package/docs.md +2 -1
- package/index.js +1649 -1617
- package/package.json +57 -56
package/README.md
CHANGED
|
@@ -1,56 +1,55 @@
|
|
|
1
|
-
# b2-cloud-storage
|
|
2
|
-
[](https://badge.fury.io/js/b2-cloud-storage)
|
|
3
|
-
[](https://david-dm.org/nodecraft/b2-cloud-storage)
|
|
4
|
-
[![
|
|
5
|
-
[![
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
- [ ]
|
|
51
|
-
- [ ] Add helper methods to
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
## License
|
|
1
|
+
# b2-cloud-storage
|
|
2
|
+
[](https://badge.fury.io/js/b2-cloud-storage)
|
|
3
|
+
[](https://david-dm.org/nodecraft/b2-cloud-storage)
|
|
4
|
+
[](https://github.com/nodecraft/b2-cloud-storage/actions)
|
|
5
|
+
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fnodecraft%2Fb2-cloud-storage?ref=badge_shield)
|
|
6
|
+
|
|
7
|
+
Backblaze B2 Cloud Storage API Client
|
|
8
|
+
|
|
9
|
+
`b2-cloud-storage` is an API wrapper for all current [Backblaze B2 API](https://www.backblaze.com/b2/docs/) operations. It provides helper methods for uploading files of all sizes, and takes care of the necessary chunking, parting, and API retries that need to happen to ensure files are uploaded successfully.
|
|
10
|
+
|
|
11
|
+
This module adheres the integration guidelines as published by Backblaze at https://www.backblaze.com/b2/docs/integration_checklist.html.
|
|
12
|
+
|
|
13
|
+
## Basic Example
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
'use strict';
|
|
17
|
+
const b2CloudStorage = require('b2-cloud-storage');
|
|
18
|
+
|
|
19
|
+
const b2 = new b2CloudStorage({
|
|
20
|
+
auth: {
|
|
21
|
+
accountId: '<accountId>', // NOTE: This is the accountId unique to the key
|
|
22
|
+
applicationKey: '<applicationKey>'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
b2.authorize(function(err){
|
|
27
|
+
if(err){ throw err; }
|
|
28
|
+
|
|
29
|
+
// this function wraps both a normal upload AND a large file upload
|
|
30
|
+
b2.uploadFile('/path/to/file.zip', {
|
|
31
|
+
bucketId: '<bucketId>',
|
|
32
|
+
fileName: 'file.zip', // this is the object storage "key". Can include a full path
|
|
33
|
+
contentType: 'application/zip',
|
|
34
|
+
onUploadProgress: function(update){
|
|
35
|
+
console.log(`Progress: ${update.percent}% (${update.bytesDispatched}/${update.bytesTotal}`);
|
|
36
|
+
// output: Progress: 9% 9012/100024
|
|
37
|
+
}
|
|
38
|
+
}, function(err, results){
|
|
39
|
+
// handle callback
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## Documentation
|
|
46
|
+
You can read the [full documentation here](docs.md).
|
|
47
|
+
|
|
48
|
+
## Roadmap:
|
|
49
|
+
- [ ] Improve unit tests and code coverage
|
|
50
|
+
- [ ] Add helper methods to delete all file versions for a single file
|
|
51
|
+
- [ ] Add helper methods to better query paginated search
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## License
|
|
56
55
|
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fnodecraft%2Fb2-cloud-storage?ref=badge_large)
|
package/docs.md
CHANGED
|
@@ -69,7 +69,8 @@ Creates new instance of the b2CloudStorage class.
|
|
|
69
69
|
<a name="b2CloudStorage+uploadFile"></a>
|
|
70
70
|
|
|
71
71
|
### b2CloudStorage.uploadFile(filename, data, [callback]) ⇒ <code>object</code>
|
|
72
|
-
Upload file with `b2_upload_file` or as several parts of a large file upload.
|
|
72
|
+
Upload file with `b2_upload_file` or as several parts of a large file upload.
|
|
73
|
+
This method also will get the filesize & sha1 hash of the entire file.
|
|
73
74
|
|
|
74
75
|
**Kind**: instance method of [<code>b2CloudStorage</code>](#b2CloudStorage)
|
|
75
76
|
**Returns**: <code>object</code> - Returns an object with 3 helper methods: `cancel()`, `progress()`, & `info()`
|