1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-13 23:20:12 +08:00

20 lines
763 B
JavaScript

// This file allows generate util functions for handle arrays, resources and all related to upload to server side
// and downdload from server side to client side. Please add the necessary functions here:
// Merge two arrays and return merged array
export function mergeByteArray(currentArray, arrayToMerge) {
const mergedArray = new currentArray.constructor(currentArray.length + arrayToMerge.length)
mergedArray.set(currentArray)
mergedArray.set(arrayToMerge, currentArray.length)
return mergedArray
}
// Build a base 64 image from array
export function buildImageFromArray(resource, byteArray) {
return 'data:' + resource.contentType + ';base64,' + btoa(
byteArray.reduce(
(data, byte) => data + String.fromCharCode(byte), ''
)
)
}