@empiricalrun/r2-uploader 0.3.2 → 0.3.4
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/CHANGELOG.md +12 -0
- package/dist/fetch.d.ts.map +1 -1
- package/dist/fetch.js +13 -7
- package/dist/upload/index.d.ts.map +1 -1
- package/dist/upload/index.js +5 -1
- package/package.json +1 -1
- package/test-assets/index.html +68 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @empiricalrun/r2-uploader
|
|
2
2
|
|
|
3
|
+
## 0.3.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ff77220: chore: return empty list when fetching a file that does not exist
|
|
8
|
+
|
|
9
|
+
## 0.3.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 267a65d: fix: mime type for file stream uploads
|
|
14
|
+
|
|
3
15
|
## 0.3.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,eAAO,MAAM,UAAU,WAAkB,aAAa;;;;
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,eAAO,MAAM,UAAU,WAAkB,aAAa;;;;gBA2BrD,CAAC"}
|
package/dist/fetch.js
CHANGED
|
@@ -17,12 +17,18 @@ const fetchFiles = async (config) => {
|
|
|
17
17
|
};
|
|
18
18
|
const cmd = new client_s3_1.ListObjectsV2Command(params);
|
|
19
19
|
const data = await S3.send(cmd);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
const { KeyCount, Contents } = data;
|
|
21
|
+
if (KeyCount === 0) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return Contents?.map((c) => {
|
|
26
|
+
return {
|
|
27
|
+
key: c.Key,
|
|
28
|
+
lastModified: c.LastModified,
|
|
29
|
+
size: c.Size,
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
27
33
|
};
|
|
28
34
|
exports.fetchFiles = fetchFiles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/upload/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/upload/index.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,OAAO,EAA8C,MAAM,UAAU,CAAC;AAqB/E,wBAAsB,eAAe,CAAC,EACpC,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,SAAS,EACT,WAAW,EACX,eAAe,GAChB,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG,OAAO,CAAC,OAAO,CAAC,CAiBnB;AAED,wBAAsB,mBAAmB,CAAC,EACxC,KAAK,EACL,cAAc,EACd,YAAY,EACZ,SAAS,EACT,WAAW,EACX,eAAe,GAChB,EAAE;IACD,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACjE,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG,OAAO,CAAC,OAAO,CAAC,CAUnB"}
|
package/dist/upload/index.js
CHANGED
|
@@ -22,9 +22,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.uploadInMemoryFiles = exports.uploadDirectory = void 0;
|
|
27
30
|
const fs = __importStar(require("fs"));
|
|
31
|
+
const mime_1 = __importDefault(require("mime"));
|
|
28
32
|
const buffer_1 = require("./buffer");
|
|
29
33
|
const stream_1 = require("./stream");
|
|
30
34
|
const getFileList = (dir) => {
|
|
@@ -49,7 +53,7 @@ async function uploadDirectory({ sourceDir, fileList, destinationDir, uploadBuck
|
|
|
49
53
|
const files = filePaths.map((filePath) => ({
|
|
50
54
|
fullPath: filePath,
|
|
51
55
|
fileName: filePath.replace(sourceDir, ""), // relative path
|
|
52
|
-
mimeType:
|
|
56
|
+
mimeType: mime_1.default.getType(filePath) || "application/octet-stream",
|
|
53
57
|
}));
|
|
54
58
|
const config = {
|
|
55
59
|
accountId: accountId || process.env.R2_ACCOUNT_ID,
|