@aws-amplify/storage
Version:
Storage category of aws-amplify
40 lines (38 loc) • 1.78 kB
JavaScript
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
Object.defineProperty(exports, "__esModule", { value: true });
exports.getProperties = void 0;
const utils_1 = require("@aws-amplify/core/internals/utils");
const utils_2 = require("../../utils");
const client_1 = require("../../utils/client");
const userAgent_1 = require("../../utils/userAgent");
const utils_3 = require("../../../../utils");
const constants_1 = require("../../utils/constants");
const getProperties = async (amplify, input, action) => {
const { options: getPropertiesOptions } = input;
const { s3Config, bucket, keyPrefix, identityId } = await (0, utils_2.resolveS3ConfigAndInput)(amplify, getPropertiesOptions);
const { inputType, objectKey } = (0, utils_2.validateStorageOperationInput)(input, identityId);
const finalKey = inputType === constants_1.STORAGE_INPUT_KEY ? keyPrefix + objectKey : objectKey;
utils_3.logger.debug(`get properties of ${objectKey} from ${finalKey}`);
const response = await (0, client_1.headObject)({
...s3Config,
userAgentValue: (0, userAgent_1.getStorageUserAgentValue)(action ?? utils_1.StorageAction.GetProperties),
}, {
Bucket: bucket,
Key: finalKey,
});
const result = {
contentType: response.ContentType,
size: response.ContentLength,
eTag: response.ETag,
lastModified: response.LastModified,
metadata: response.Metadata,
versionId: response.VersionId,
};
return inputType === constants_1.STORAGE_INPUT_KEY
? { key: objectKey, ...result }
: { path: objectKey, ...result };
};
exports.getProperties = getProperties;
//# sourceMappingURL=getProperties.js.map
;