@naturalcycles/cloud-storage-lib 1.0.1 → 1.1.0
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.
|
@@ -31,6 +31,8 @@ export declare class CommonStorageBucket {
|
|
|
31
31
|
content: T;
|
|
32
32
|
}[]>;
|
|
33
33
|
saveFile(filePath: string, content: Buffer): Promise<void>;
|
|
34
|
+
saveStringFile(filePath: string, content: string): Promise<void>;
|
|
35
|
+
saveJsonFile(filePath: string, content: any): Promise<void>;
|
|
34
36
|
saveFiles(entries: FileEntry[]): Promise<void>;
|
|
35
37
|
/**
|
|
36
38
|
* Should recursively delete all files in a folder, if path is a folder.
|
|
@@ -73,6 +73,12 @@ class CommonStorageBucket {
|
|
|
73
73
|
async saveFile(filePath, content) {
|
|
74
74
|
await this.cfg.storage.saveFile(this.cfg.bucketName, filePath, content);
|
|
75
75
|
}
|
|
76
|
+
async saveStringFile(filePath, content) {
|
|
77
|
+
await this.cfg.storage.saveFile(this.cfg.bucketName, filePath, Buffer.from(content));
|
|
78
|
+
}
|
|
79
|
+
async saveJsonFile(filePath, content) {
|
|
80
|
+
await this.cfg.storage.saveFile(this.cfg.bucketName, filePath, Buffer.from(JSON.stringify(content)));
|
|
81
|
+
}
|
|
76
82
|
async saveFiles(entries) {
|
|
77
83
|
await (0, js_lib_1.pMap)(entries, async (f) => {
|
|
78
84
|
await this.cfg.storage.saveFile(this.cfg.bucketName, f.filePath, f.content);
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
> CommonStorage implementation based on Google Cloud Storage
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@naturalcycles/cloud-storage-lib)
|
|
6
|
-
[](https://bundlephobia.com/result?p=@naturalcycles/cloud-storage-lib)
|
|
7
6
|
[](https://github.com/prettier/prettier)
|
|
8
7
|
|
|
9
8
|
Implements:
|
|
@@ -103,6 +103,18 @@ export class CommonStorageBucket {
|
|
|
103
103
|
await this.cfg.storage.saveFile(this.cfg.bucketName, filePath, content)
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
async saveStringFile(filePath: string, content: string): Promise<void> {
|
|
107
|
+
await this.cfg.storage.saveFile(this.cfg.bucketName, filePath, Buffer.from(content))
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async saveJsonFile(filePath: string, content: any): Promise<void> {
|
|
111
|
+
await this.cfg.storage.saveFile(
|
|
112
|
+
this.cfg.bucketName,
|
|
113
|
+
filePath,
|
|
114
|
+
Buffer.from(JSON.stringify(content)),
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
|
|
106
118
|
async saveFiles(entries: FileEntry[]): Promise<void> {
|
|
107
119
|
await pMap(entries, async f => {
|
|
108
120
|
await this.cfg.storage.saveFile(this.cfg.bucketName, f.filePath, f.content)
|