@rowengine/common 1.1.4 → 1.1.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/build/utils/gc.d.ts +1 -0
- package/build/utils/gc.js +11 -2
- package/build/utils/index.d.ts +0 -1
- package/build/utils/index.js +0 -1
- package/package.json +1 -1
package/build/utils/gc.d.ts
CHANGED
|
@@ -8,4 +8,5 @@ interface UploadFileToGCSResponse {
|
|
|
8
8
|
}
|
|
9
9
|
export declare const uploadFileToGCS: ({ filePath, gcsFilePath, }: UploadFileToGCS) => Promise<UploadFileToGCSResponse>;
|
|
10
10
|
export declare const uploadFolderToGCS: (folderPath: string, gcsPath: string) => Promise<void>;
|
|
11
|
+
export declare const downloadProjectFileFromGCS: (projectId: string, fileName: string, destinationPath: string) => Promise<string | null>;
|
|
11
12
|
export {};
|
package/build/utils/gc.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.uploadFolderToGCS = exports.uploadFileToGCS = void 0;
|
|
15
|
+
exports.downloadProjectFileFromGCS = exports.uploadFolderToGCS = exports.uploadFileToGCS = void 0;
|
|
16
16
|
const gc_storage_1 = __importDefault(require("./gc-storage"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -58,6 +58,15 @@ const uploadFolderToGCS = (folderPath, gcsPath) => __awaiter(void 0, void 0, voi
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
const res = yield Promise.all(promises);
|
|
61
|
-
const totalSize = res.reduce((acc, curr) => acc + curr.size, 0);
|
|
62
61
|
});
|
|
63
62
|
exports.uploadFolderToGCS = uploadFolderToGCS;
|
|
63
|
+
const downloadProjectFileFromGCS = (projectId, fileName, destinationPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
const gcFilePath = `projects/${projectId}/${fileName}`;
|
|
65
|
+
const gcFile = gc_storage_1.default.file(gcFilePath);
|
|
66
|
+
const [fileExists] = yield gcFile.exists();
|
|
67
|
+
if (!fileExists)
|
|
68
|
+
return null;
|
|
69
|
+
yield gcFile.download({ destination: destinationPath });
|
|
70
|
+
return destinationPath;
|
|
71
|
+
});
|
|
72
|
+
exports.downloadProjectFileFromGCS = downloadProjectFileFromGCS;
|
package/build/utils/index.d.ts
CHANGED
package/build/utils/index.js
CHANGED
|
@@ -16,4 +16,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./grades"), exports);
|
|
18
18
|
__exportStar(require("./gc"), exports);
|
|
19
|
-
__exportStar(require("./gc-storage"), exports);
|