@aws-amplify/storage
Version:
Storage category of aws-amplify
1 lines • 1.96 kB
Source Map (JSON)
{"version":3,"file":"getCombinedCrc32.mjs","sources":["../../../../../src/providers/s3/utils/getCombinedCrc32.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getDataChunker } from '../apis/internal/uploadData/multipart/getDataChunker';\nimport { calculateContentCRC32 } from './crc32';\n/**\n * Calculates a combined CRC32 checksum for the given data.\n *\n * This function chunks the input data, calculates CRC32 for each chunk,\n * and then combines these checksums into a single value.\n *\n * @async\n * @param {StorageUploadDataPayload} data - The data to calculate the checksum for.\n * @param {number | undefined} size - The size of each chunk. If undefined, a default chunk size will be used.\n * @returns {Promise<string>} A promise that resolves to a string containing the combined CRC32 checksum\n * and the number of chunks, separated by a hyphen.\n */\nexport const getCombinedCrc32 = async (data, size) => {\n const crc32List = [];\n const dataChunker = getDataChunker(data, size);\n for (const { data: checkData } of dataChunker) {\n const { checksumArrayBuffer } = await calculateContentCRC32(checkData);\n crc32List.push(checksumArrayBuffer);\n }\n return `${(await calculateContentCRC32(new Blob(crc32List))).checksum}-${crc32List.length}`;\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,gBAAgB,GAAG,OAAO,IAAI,EAAE,IAAI,KAAK;AACtD,IAAI,MAAM,SAAS,GAAG,EAAE;AACxB,IAAI,MAAM,WAAW,GAAG,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC;AAClD,IAAI,KAAK,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,WAAW,EAAE;AACnD,QAAQ,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,qBAAqB,CAAC,SAAS,CAAC;AAC9E,QAAQ,SAAS,CAAC,IAAI,CAAC,mBAAmB,CAAC;AAC3C;AACA,IAAI,OAAO,CAAC,EAAE,CAAC,MAAM,qBAAqB,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;AAC/F;;;;"}