UNPKG

@aws-amplify/storage

Version:

Storage category of aws-amplify

17 lines (15 loc) 565 B
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 /** * Client-side `toBase64` implementation for browsers: uses `btoa` + * `TextEncoder`. */ const toBase64 = input => { const bytes = typeof input === 'string' ? new TextEncoder().encode(input) : new Uint8Array(input.buffer, input.byteOffset, input.byteLength); const base64Str = Array.from(bytes, x => String.fromCodePoint(x)).join(''); return btoa(base64Str); }; export { toBase64 }; //# sourceMappingURL=toBase64.mjs.map