@stemy/backend 3.4.4 → 3.4.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.
|
@@ -1876,11 +1876,21 @@
|
|
|
1876
1876
|
Assets.prototype.writeUrl = function (url, metadata) {
|
|
1877
1877
|
if (metadata === void 0) { metadata = null; }
|
|
1878
1878
|
return __awaiter$r(this, void 0, void 0, function () {
|
|
1879
|
-
var buffer;
|
|
1879
|
+
var oneWeek, asset, buffer;
|
|
1880
1880
|
return __generator(this, function (_b) {
|
|
1881
1881
|
switch (_b.label) {
|
|
1882
|
-
case 0:
|
|
1882
|
+
case 0:
|
|
1883
|
+
metadata = metadata || {};
|
|
1884
|
+
metadata.filename = url;
|
|
1885
|
+
metadata.uploadTime = new Date().getTime();
|
|
1886
|
+
oneWeek = 1000 * 3600 * 24 * 7;
|
|
1887
|
+
return [4 /*yield*/, this.find({ filename: url, "metadata.uploadTime": { $gt: metadata.uploadTime - oneWeek } })];
|
|
1883
1888
|
case 1:
|
|
1889
|
+
asset = _b.sent();
|
|
1890
|
+
if (asset)
|
|
1891
|
+
return [2 /*return*/, asset];
|
|
1892
|
+
return [4 /*yield*/, axios__default["default"]({ url: url, responseType: "arraybuffer" })];
|
|
1893
|
+
case 2:
|
|
1884
1894
|
buffer = (_b.sent()).data;
|
|
1885
1895
|
return [2 /*return*/, this.writeBuffer(buffer, metadata)];
|
|
1886
1896
|
}
|