UNPKG

@aws-amplify/storage

Version:

Storage category of aws-amplify

47 lines (45 loc) 1.99 kB
'use strict'; // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 Object.defineProperty(exports, "__esModule", { value: true }); exports.headObject = void 0; const aws_client_utils_1 = require("@aws-amplify/core/internals/aws-client-utils"); const utils_1 = require("@aws-amplify/core/internals/utils"); const composers_1 = require("@aws-amplify/core/internals/aws-client-utils/composers"); const base_1 = require("./base"); const utils_2 = require("./utils"); const headObjectSerializer = async (input, endpoint) => { const url = new utils_1.AmplifyUrl(endpoint.url.toString()); (0, utils_2.validateS3RequiredParameter)(!!input.Key, 'Key'); url.pathname = (0, utils_2.serializePathnameObjectKey)(url, input.Key); return { method: 'HEAD', headers: {}, url, }; }; const headObjectDeserializer = async (response) => { if (response.statusCode >= 300) { // error is always set when statusCode >= 300 const error = (await (0, utils_2.parseXmlError)(response)); throw (0, utils_2.buildStorageServiceError)(error, response.statusCode); } else { const contents = { ...(0, utils_2.map)(response.headers, { ContentLength: ['content-length', utils_2.deserializeNumber], ContentType: 'content-type', ETag: 'etag', LastModified: ['last-modified', utils_2.deserializeTimestamp], VersionId: 'x-amz-version-id', }), Metadata: (0, utils_2.deserializeMetadata)(response.headers), }; return { $metadata: (0, aws_client_utils_1.parseMetadata)(response), ...contents, }; } }; exports.headObject = (0, composers_1.composeServiceApi)(utils_2.s3TransferHandler, headObjectSerializer, headObjectDeserializer, { ...base_1.defaultConfig, responseType: 'text' }); //# sourceMappingURL=headObject.js.map