code: function bytes2base64(buffer) {
              var str = '';
              var length;
              var i;
              // ArrayBuffer
              if (buffer instanceof ArrayBuffer) {
                  length = buffer.byteLength;
                  var view = new DataView(buffer, 0, length);
                  for (i = 0; i < length; i++) {
                      str += String.fromCharCode(view.getUint8(i, false));
                  }
              }
              // Array
              else if (buffer.length) {
                  length = buffer.length;
                  for (i = 0; i < length; i++) {
                      str += String.fromCharCode(buffer[i]);
                  }
              }
  
              return btoa(str);
          }
docs: 二进制byte流转base64编码
  
  @param {ArrayBuffer|Array} buffer ArrayBuffer对象
  @return {string} base64编码