@aws-sdk/lib-storage 3.32.0 → 3.36.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.
Files changed (97) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist-cjs/Upload.js +179 -0
  3. package/dist-cjs/bytelength.js +29 -0
  4. package/dist-cjs/chunker.js +30 -0
  5. package/dist-cjs/chunks/getChunkBuffer.js +23 -0
  6. package/dist-cjs/chunks/getChunkStream.js +28 -0
  7. package/dist-cjs/chunks/getDataReadable.js +10 -0
  8. package/dist-cjs/chunks/getDataReadableStream.js +22 -0
  9. package/dist-cjs/index.js +5 -0
  10. package/dist-cjs/runtimeConfig.browser.js +8 -0
  11. package/dist-cjs/runtimeConfig.js +10 -0
  12. package/dist-cjs/runtimeConfig.native.js +8 -0
  13. package/dist-cjs/runtimeConfig.shared.js +6 -0
  14. package/dist-cjs/types.js +2 -0
  15. package/dist-es/Upload.js +261 -0
  16. package/dist-es/bytelength.js +25 -0
  17. package/dist-es/chunker.js +26 -0
  18. package/dist-es/chunks/getChunkBuffer.js +37 -0
  19. package/dist-es/chunks/getChunkStream.js +68 -0
  20. package/dist-es/chunks/getDataReadable.js +44 -0
  21. package/dist-es/chunks/getDataReadableStream.js +38 -0
  22. package/{dist/types/index.d.ts → dist-es/index.js} +0 -0
  23. package/dist-es/runtimeConfig.browser.js +3 -0
  24. package/dist-es/runtimeConfig.js +4 -0
  25. package/dist-es/runtimeConfig.native.js +3 -0
  26. package/dist-es/runtimeConfig.shared.js +3 -0
  27. package/{dist/types/runtimeConfig.browser.d.ts → dist-es/types.js} +0 -0
  28. package/{dist/types → dist-types}/Upload.d.ts +0 -0
  29. package/{dist/types → dist-types}/bytelength.d.ts +0 -0
  30. package/{dist/types → dist-types}/chunker.d.ts +0 -0
  31. package/{dist/types → dist-types}/chunks/getChunkBuffer.d.ts +0 -0
  32. package/{dist/types → dist-types}/chunks/getChunkStream.d.ts +0 -0
  33. package/{dist/types → dist-types}/chunks/getDataReadable.d.ts +0 -0
  34. package/{dist/types → dist-types}/chunks/getDataReadableStream.d.ts +0 -0
  35. package/dist-types/index.d.ts +2 -0
  36. package/dist-types/runtimeConfig.browser.d.ts +7 -0
  37. package/dist-types/runtimeConfig.d.ts +9 -0
  38. package/dist-types/runtimeConfig.native.d.ts +7 -0
  39. package/dist-types/runtimeConfig.shared.d.ts +6 -0
  40. package/{dist/types → dist-types}/ts3.4/Upload.d.ts +0 -0
  41. package/{dist/types → dist-types}/ts3.4/bytelength.d.ts +0 -0
  42. package/{dist/types → dist-types}/ts3.4/chunker.d.ts +0 -0
  43. package/{dist/types → dist-types}/ts3.4/chunks/getChunkBuffer.d.ts +0 -0
  44. package/{dist/types → dist-types}/ts3.4/chunks/getChunkStream.d.ts +0 -0
  45. package/{dist/types → dist-types}/ts3.4/chunks/getDataReadable.d.ts +0 -0
  46. package/{dist/types → dist-types}/ts3.4/chunks/getDataReadableStream.d.ts +0 -0
  47. package/{dist/types → dist-types}/ts3.4/index.d.ts +0 -0
  48. package/dist-types/ts3.4/runtimeConfig.browser.d.ts +7 -0
  49. package/dist-types/ts3.4/runtimeConfig.d.ts +9 -0
  50. package/dist-types/ts3.4/runtimeConfig.native.d.ts +7 -0
  51. package/dist-types/ts3.4/runtimeConfig.shared.d.ts +6 -0
  52. package/{dist/types → dist-types}/ts3.4/types.d.ts +0 -0
  53. package/{dist/types → dist-types}/types.d.ts +0 -0
  54. package/package.json +15 -10
  55. package/dist/cjs/Upload.js +0 -198
  56. package/dist/cjs/bytelength.js +0 -30
  57. package/dist/cjs/chunker.js +0 -33
  58. package/dist/cjs/chunks/getChunkBuffer.js +0 -24
  59. package/dist/cjs/chunks/getChunkStream.js +0 -34
  60. package/dist/cjs/chunks/getDataReadable.js +0 -11
  61. package/dist/cjs/chunks/getDataReadableStream.js +0 -28
  62. package/dist/cjs/index.js +0 -6
  63. package/dist/cjs/runtimeConfig.browser.js +0 -12
  64. package/dist/cjs/runtimeConfig.js +0 -14
  65. package/dist/cjs/runtimeConfig.native.js +0 -12
  66. package/dist/cjs/runtimeConfig.shared.js +0 -10
  67. package/dist/cjs/types.js +0 -3
  68. package/dist/es/Upload.js +0 -278
  69. package/dist/es/bytelength.js +0 -26
  70. package/dist/es/chunker.js +0 -29
  71. package/dist/es/chunks/getChunkBuffer.js +0 -38
  72. package/dist/es/chunks/getChunkStream.js +0 -70
  73. package/dist/es/chunks/getDataReadable.js +0 -45
  74. package/dist/es/chunks/getDataReadableStream.js +0 -43
  75. package/dist/es/index.js +0 -3
  76. package/dist/es/runtimeConfig.browser.js +0 -7
  77. package/dist/es/runtimeConfig.js +0 -8
  78. package/dist/es/runtimeConfig.native.js +0 -7
  79. package/dist/es/runtimeConfig.shared.js +0 -7
  80. package/dist/es/types.js +0 -2
  81. package/dist/types/runtimeConfig.d.ts +0 -1
  82. package/dist/types/runtimeConfig.native.d.ts +0 -1
  83. package/dist/types/runtimeConfig.shared.d.ts +0 -1
  84. package/dist/types/ts3.4/runtimeConfig.browser.d.ts +0 -1
  85. package/dist/types/ts3.4/runtimeConfig.d.ts +0 -1
  86. package/dist/types/ts3.4/runtimeConfig.native.d.ts +0 -1
  87. package/dist/types/ts3.4/runtimeConfig.shared.d.ts +0 -1
  88. package/example-code/config.ts +0 -4
  89. package/example-code/file-upload.ts +0 -24
  90. package/example-code/upload-abort.ts +0 -48
  91. package/example-code/upload-string.ts +0 -22
  92. package/example-code/upload-unknown-length-browser.ts +0 -57
  93. package/example-code/upload-unknown-length.ts +0 -43
  94. package/jest.config.js +0 -5
  95. package/karma.conf.js +0 -28
  96. package/tsconfig.cjs.json +0 -19
  97. package/tsconfig.es.json +0 -19
package/dist/es/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMudHMiX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
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export const configuration = {
2
- Bucket: "test-bucket-1234567890",
3
- Key: `unique-key-${Date.now}`,
4
- };
@@ -1,24 +0,0 @@
1
- import * as fs from "fs";
2
- import { Upload } from "@aws-sdk/lib-storage";
3
- import { S3 } from "@aws-sdk/client-s3";
4
- import { configuration } from "./config";
5
-
6
- const fileStream = fs.createReadStream(__dirname + "/big.file");
7
-
8
- (async () => {
9
- const upload = new Upload({
10
- params: {
11
- Bucket: configuration.Bucket,
12
- Key: configuration.Key,
13
- Body: fileStream,
14
- },
15
- client: new S3({}),
16
- queueSize: 3,
17
- });
18
-
19
- upload.on("httpUploadProgress", (progress) => {
20
- console.log(progress);
21
- });
22
-
23
- await upload.done();
24
- })();
@@ -1,48 +0,0 @@
1
- import { S3Client } from "@aws-sdk/client-s3";
2
- import { Upload } from "@aws-sdk/lib-storage";
3
- import { configuration } from "./config";
4
- import { Readable } from "stream";
5
-
6
- const Bucket = configuration.Bucket;
7
- const region = "us-west-2";
8
-
9
- const sleep = async (seconds: number) => {
10
- return new Promise((resolve) => setTimeout(resolve, seconds * 1000));
11
- };
12
-
13
- async function* generateContents() {
14
- for (let index = 0; index < 8; index++) {
15
- const time = Math.random() * 5;
16
- await sleep(time);
17
- console.log(`Delaying part ${index} for ${time}`);
18
- yield `[Part ${index}] ${"#".repeat(2000000)}`;
19
- }
20
- }
21
-
22
- const uploadIndeterminateLengthStreamNode = async () => {
23
- const streamOfUnknownlength = Readable.from(generateContents());
24
-
25
- const Key = configuration.Key;
26
- let upload = new Upload({
27
- client: new S3Client({ region }),
28
- params: {
29
- Key,
30
- Bucket,
31
- Body: streamOfUnknownlength,
32
- },
33
- });
34
-
35
- upload.on("httpUploadProgress", (progress: ProgressEvent) => {
36
- console.log(progress);
37
- });
38
-
39
- setTimeout(() => {
40
- console.log(" Aborting ....");
41
- let res = upload.abort();
42
- }, 10 * 1000);
43
-
44
- const uploadResult = await upload.done();
45
- console.log("done uploading", uploadResult);
46
- };
47
-
48
- uploadIndeterminateLengthStreamNode();
@@ -1,22 +0,0 @@
1
- import { Upload } from "@aws-sdk/lib-storage";
2
- import { S3 } from "@aws-sdk/client-s3";
3
- import { configuration } from "./config";
4
-
5
- const Bucket = configuration.Bucket;
6
- const Key = configuration.Key;
7
- const Body =
8
- "Duo Reges: constructio interrete. Qui autem esse poteris, nisi te amor ipse ceperit? Hoc est non modo cor non habere, sed ne palatum quidem. Quantam rem agas, ut Circeis qui habitet totum hunc mundum suum municipium esse existimet? Huius, Lyco, oratione locuples, rebus ipsis ielunior. Sed quid attinet de rebus tam apertis plura requirere? Non quam nostram quidem, inquit Pomponius iocans; Alterum significari idem, ut si diceretur, officia media omnia aut pleraque servantem vivere. Stoici scilicet";
9
-
10
- (async () => {
11
- const target = { Bucket, Key, Body };
12
- const parallelUploads3 = new Upload({
13
- client: new S3({}),
14
- params: target,
15
- });
16
-
17
- parallelUploads3.on("httpUploadProgress", (progress) => {
18
- console.log(progress);
19
- });
20
-
21
- await parallelUploads3.done();
22
- })();
@@ -1,57 +0,0 @@
1
- import { fromCognitoIdentityPool } from "@aws-sdk/credential-provider-cognito-identity";
2
- import { CognitoIdentityClient } from "@aws-sdk/client-cognito-identity";
3
-
4
- import { S3Client } from "@aws-sdk/client-s3";
5
- import { Upload } from "@aws-sdk/lib-storage";
6
-
7
- import { configuration } from "./config";
8
-
9
- const idPool = "us-west-2:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
10
- const Bucket = configuration.Bucket;
11
- const region = "us-west-2";
12
-
13
- const sleep = async (seconds: number) => {
14
- return new Promise((resolve) => setTimeout(resolve, seconds * 1000));
15
- };
16
-
17
- const fakeStreamOfUnknownlength = new ReadableStream({
18
- start: async (controller) => {
19
- for (let index = 0; index < 8; index++) {
20
- const time = Math.random() * 5;
21
- await sleep(time);
22
- console.log(`Delaying part ${index} for ${time}`);
23
- controller.enqueue(`[part ${index}] with ${"#".repeat(2000000)}`);
24
- }
25
- controller.close();
26
- },
27
- });
28
-
29
- const uploadIndeterminateLengthStreamBrowser = async () => {
30
- const client = new S3Client({
31
- region,
32
- credentials: fromCognitoIdentityPool({
33
- client: new CognitoIdentityClient({ region }),
34
- identityPoolId: idPool,
35
- }),
36
- });
37
-
38
- const Key = configuration.Key;
39
-
40
- let upload = new Upload({
41
- client,
42
- params: {
43
- Key,
44
- Bucket,
45
- Body: fakeStreamOfUnknownlength,
46
- },
47
- });
48
-
49
- upload.on("httpUploadProgress", (progress: ProgressEvent) => {
50
- console.log(progress);
51
- });
52
-
53
- const uploadResult = await upload.done();
54
- console.log("done uploading", uploadResult);
55
- };
56
-
57
- uploadIndeterminateLengthStreamBrowser();
@@ -1,43 +0,0 @@
1
- import { S3Client } from "@aws-sdk/client-s3";
2
- import { Upload } from "@aws-sdk/lib-storage";
3
-
4
- import { Readable } from "stream";
5
- import { configuration } from "./config";
6
-
7
- const Bucket = configuration.Bucket;
8
- const region = "us-west-2";
9
-
10
- const sleep = async (seconds: number) => {
11
- return new Promise((resolve) => setTimeout(resolve, seconds * 1000));
12
- };
13
-
14
- async function* generateContents() {
15
- for (let index = 0; index < 8; index++) {
16
- const time = Math.random() * 10;
17
- await sleep(time);
18
- console.log(`Delaying part ${index} for ${time}`);
19
- yield `[Part ${index}] ${"#".repeat(2000000)}`;
20
- }
21
- }
22
- const fakeStreamOfUnknownlength = Readable.from(generateContents());
23
-
24
- const uploadIndeterminateLengthStreamNode = async () => {
25
- const Key = configuration.Key;
26
- let upload = new Upload({
27
- client: new S3Client({ region }),
28
- params: {
29
- Key,
30
- Bucket,
31
- Body: fakeStreamOfUnknownlength,
32
- },
33
- });
34
-
35
- upload.on("httpUploadProgress", (progress: ProgressEvent) => {
36
- console.log(progress);
37
- });
38
-
39
- const uploadResult = await upload.done();
40
- console.log("done uploading", uploadResult);
41
- };
42
-
43
- uploadIndeterminateLengthStreamNode();
package/jest.config.js DELETED
@@ -1,5 +0,0 @@
1
- const base = require("../../jest.config.base.js");
2
-
3
- module.exports = {
4
- ...base,
5
- };
package/karma.conf.js DELETED
@@ -1,28 +0,0 @@
1
- module.exports = function (config) {
2
- config.set({
3
- frameworks: ["jasmine", "karma-typescript"],
4
- files: [
5
- { pattern: "src/**/*.ts", include: "false" },
6
- { pattern: "test/browser/upload.browser-spec.ts", include: "false" },
7
- ],
8
- exclude: ["**/*.d.ts"],
9
- preprocessors: {
10
- "**/*.ts": "karma-typescript",
11
- },
12
- reporters: ["spec", "karma-typescript"],
13
- browsers: ["ChromeHeadlessNoSandbox"],
14
- customLaunchers: {
15
- ChromeHeadlessNoSandbox: {
16
- base: "ChromeHeadless",
17
- flags: ["--no-sandbox"],
18
- },
19
- },
20
- karmaTypescriptConfig: {
21
- tsconfig: "./tsconfig.json",
22
- bundlerOptions: {
23
- addNodeGlobals: true,
24
- },
25
- },
26
- singleRun: true,
27
- });
28
- };
package/tsconfig.cjs.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "lib": ["es5", "es2015.collection", "dom"],
4
- "strict": true,
5
- "sourceMap": false,
6
- "declaration": true,
7
- "stripInternal": true,
8
- "declarationDir": "./dist/types",
9
- "rootDir": "./src",
10
- "outDir": "./dist/cjs",
11
- "importHelpers": true,
12
- "noEmitHelpers": true,
13
- "inlineSourceMap": true,
14
- "inlineSources": true,
15
- "baseUrl": "."
16
- },
17
- "extends": "../../tsconfig.cjs.json",
18
- "include": ["src/"]
19
- }
package/tsconfig.es.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "lib": ["es5", "es2015.collection", "dom"],
4
- "strict": true,
5
- "sourceMap": false,
6
- "declaration": true,
7
- "stripInternal": true,
8
- "declarationDir": "./dist/types",
9
- "rootDir": "./src",
10
- "outDir": "./dist/es",
11
- "importHelpers": true,
12
- "noEmitHelpers": true,
13
- "inlineSourceMap": true,
14
- "inlineSources": true,
15
- "baseUrl": "."
16
- },
17
- "extends": "../../tsconfig.es.json",
18
- "include": ["src/"]
19
- }