@aws-sdk/middleware-sdk-s3 3.78.0 → 3.86.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.86.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.85.0...v3.86.0) (2022-05-06)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **middleware-sdk-s3:** improve error message on stream upload ([#3571](https://github.com/aws/aws-sdk-js-v3/issues/3571)) ([c0ed833](https://github.com/aws/aws-sdk-js-v3/commit/c0ed83347f571b3f5d1e41dc91c172abafb44b7b))
12
+
13
+
14
+
15
+
16
+
6
17
  # [3.78.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.77.0...v3.78.0) (2022-04-26)
7
18
 
8
19
  **Note:** Version bump only for package @aws-sdk/middleware-sdk-s3
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCheckContentLengthHeaderPlugin = exports.checkContentLengthHeaderMiddlewareOptions = exports.checkContentLengthHeader = void 0;
4
+ const protocol_http_1 = require("@aws-sdk/protocol-http");
5
+ const CONTENT_LENGTH_HEADER = "content-length";
6
+ function checkContentLengthHeader() {
7
+ return (next, context) => async (args) => {
8
+ var _a;
9
+ const { request } = args;
10
+ if (protocol_http_1.HttpRequest.isInstance(request)) {
11
+ if (!request.headers[CONTENT_LENGTH_HEADER]) {
12
+ const message = `Are you using a Stream of unknown length as the Body of a PutObject request? Consider using Upload instead from @aws-sdk/lib-storage.`;
13
+ if (typeof ((_a = context === null || context === void 0 ? void 0 : context.logger) === null || _a === void 0 ? void 0 : _a.warn) === "function") {
14
+ context.logger.warn(message);
15
+ }
16
+ else {
17
+ console.warn(message);
18
+ }
19
+ }
20
+ }
21
+ return next({ ...args });
22
+ };
23
+ }
24
+ exports.checkContentLengthHeader = checkContentLengthHeader;
25
+ exports.checkContentLengthHeaderMiddlewareOptions = {
26
+ step: "finalizeRequest",
27
+ tags: ["CHECK_CONTENT_LENGTH_HEADER"],
28
+ name: "getCheckContentLengthHeaderPlugin",
29
+ override: true,
30
+ };
31
+ const getCheckContentLengthHeaderPlugin = (unused) => ({
32
+ applyToStack: (clientStack) => {
33
+ clientStack.add(checkContentLengthHeader(), exports.checkContentLengthHeaderMiddlewareOptions);
34
+ },
35
+ });
36
+ exports.getCheckContentLengthHeaderPlugin = getCheckContentLengthHeaderPlugin;
package/dist-cjs/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./check-content-length-header"), exports);
4
5
  tslib_1.__exportStar(require("./throw-200-exceptions"), exports);
5
6
  tslib_1.__exportStar(require("./use-regional-endpoint"), exports);
6
7
  tslib_1.__exportStar(require("./validate-bucket-name"), exports);
@@ -0,0 +1,38 @@
1
+ import { __assign, __awaiter, __generator } from "tslib";
2
+ import { HttpRequest } from "@aws-sdk/protocol-http";
3
+ var CONTENT_LENGTH_HEADER = "content-length";
4
+ export function checkContentLengthHeader() {
5
+ var _this = this;
6
+ return function (next, context) {
7
+ return function (args) { return __awaiter(_this, void 0, void 0, function () {
8
+ var request, message;
9
+ var _a;
10
+ return __generator(this, function (_b) {
11
+ request = args.request;
12
+ if (HttpRequest.isInstance(request)) {
13
+ if (!request.headers[CONTENT_LENGTH_HEADER]) {
14
+ message = "Are you using a Stream of unknown length as the Body of a PutObject request? Consider using Upload instead from @aws-sdk/lib-storage.";
15
+ if (typeof ((_a = context === null || context === void 0 ? void 0 : context.logger) === null || _a === void 0 ? void 0 : _a.warn) === "function") {
16
+ context.logger.warn(message);
17
+ }
18
+ else {
19
+ console.warn(message);
20
+ }
21
+ }
22
+ }
23
+ return [2, next(__assign({}, args))];
24
+ });
25
+ }); };
26
+ };
27
+ }
28
+ export var checkContentLengthHeaderMiddlewareOptions = {
29
+ step: "finalizeRequest",
30
+ tags: ["CHECK_CONTENT_LENGTH_HEADER"],
31
+ name: "getCheckContentLengthHeaderPlugin",
32
+ override: true,
33
+ };
34
+ export var getCheckContentLengthHeaderPlugin = function (unused) { return ({
35
+ applyToStack: function (clientStack) {
36
+ clientStack.add(checkContentLengthHeader(), checkContentLengthHeaderMiddlewareOptions);
37
+ },
38
+ }); };
package/dist-es/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./check-content-length-header";
1
2
  export * from "./throw-200-exceptions";
2
3
  export * from "./use-regional-endpoint";
3
4
  export * from "./validate-bucket-name";
@@ -0,0 +1,16 @@
1
+ import { FinalizeRequestHandlerOptions, FinalizeRequestMiddleware, Pluggable } from "@aws-sdk/types";
2
+ /**
3
+ * @internal
4
+ *
5
+ * Log a warning if the input to PutObject is detected to be a Stream of unknown ContentLength and
6
+ * recommend the usage of the @aws-sdk/lib-storage Upload class.
7
+ */
8
+ export declare function checkContentLengthHeader(): FinalizeRequestMiddleware<any, any>;
9
+ /**
10
+ * @internal
11
+ */
12
+ export declare const checkContentLengthHeaderMiddlewareOptions: FinalizeRequestHandlerOptions;
13
+ /**
14
+ * @internal
15
+ */
16
+ export declare const getCheckContentLengthHeaderPlugin: (unused: any) => Pluggable<any, any>;
@@ -1,3 +1,4 @@
1
+ export * from "./check-content-length-header";
1
2
  export * from "./throw-200-exceptions";
2
3
  export * from "./use-regional-endpoint";
3
4
  export * from "./validate-bucket-name";
@@ -0,0 +1,7 @@
1
+ import { FinalizeRequestHandlerOptions, FinalizeRequestMiddleware, Pluggable } from "@aws-sdk/types";
2
+
3
+ export declare function checkContentLengthHeader(): FinalizeRequestMiddleware<any, any>;
4
+
5
+ export declare const checkContentLengthHeaderMiddlewareOptions: FinalizeRequestHandlerOptions;
6
+
7
+ export declare const getCheckContentLengthHeaderPlugin: (unused: any) => Pluggable<any, any>;
@@ -1,3 +1,4 @@
1
+ export * from "./check-content-length-header";
1
2
  export * from "./throw-200-exceptions";
2
3
  export * from "./use-regional-endpoint";
3
4
  export * from "./validate-bucket-name";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-sdk-s3",
3
- "version": "3.78.0",
3
+ "version": "3.86.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "tsc -p tsconfig.cjs.json",