@aws-amplify/storage
Version:
Storage category of aws-amplify
1 lines • 1.21 kB
Source Map (JSON)
{"version":3,"file":"md5.mjs","sources":["../../../../src/foundation/utils/md5.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Md5 } from '@smithy/md5-js';\n/**\n * Calculate the MD5 checksum of the given content as a base64 string.\n * Environment-specific dependencies (`readFile`, `toBase64`) are injected\n * via the {@link FoundationContext} so the foundation layer stays free of\n * any environment-discriminating logic.\n */\nexport const calculateContentMd5 = async (ctx, content) => {\n const hasher = new Md5();\n const buffer = content instanceof Blob ? await ctx.readFile(content) : content;\n hasher.update(buffer);\n const digest = await hasher.digest();\n return ctx.toBase64(digest);\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,mBAAmB,GAAG,OAAO,GAAG,EAAE,OAAO,KAAK;AAC3D,IAAI,MAAM,MAAM,GAAG,IAAI,GAAG,EAAE;AAC5B,IAAI,MAAM,MAAM,GAAG,OAAO,YAAY,IAAI,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,OAAO;AAClF,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;AACzB,IAAI,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,EAAE;AACxC,IAAI,OAAO,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;AAC/B;;;;"}