@@ -45,30 +45,6 @@ module.exports = function(AV) {
4545 return chunks . join ( "" ) ;
4646 } ;
4747
48-
49- var dataURItoBlob = function ( dataURI , type ) {
50- // convert base64/URLEncoded data component to raw binary data held in a string
51- var byteString ;
52-
53- // 传入的 base64,不是 dataURL
54- if ( dataURI . indexOf ( 'base64' ) < 0 ) {
55- byteString = atob ( dataURI ) ;
56- } else if ( dataURI . split ( ',' ) [ 0 ] . indexOf ( 'base64' ) >= 0 ) {
57- byteString = atob ( dataURI . split ( ',' ) [ 1 ] ) ;
58- } else {
59- byteString = unescape ( dataURI . split ( ',' ) [ 1 ] ) ;
60- }
61- // separate out the mime component
62- var mimeString = type || dataURI . split ( ',' ) [ 0 ] . split ( ':' ) [ 1 ] . split ( ';' ) [ 0 ] ;
63-
64- // write the bytes of the string to a typed array
65- var ia = new Uint8Array ( byteString . length ) ;
66- for ( var i = 0 ; i < byteString . length ; i ++ ) {
67- ia [ i ] = byteString . charCodeAt ( i ) ;
68- }
69- return new Blob ( [ ia ] , { type :mimeString } ) ;
70- } ;
71-
7248 // A list of file extensions to mime types as found here:
7349 // http://stackoverflow.com/questions/58510/using-net-how-can-you-find-the-
7450 // mime-type-of-a-file-based-on-the-file-signature
@@ -353,8 +329,8 @@ module.exports = function(AV) {
353329 this . _source = AV . Promise . as ( encodeBase64 ( data ) , guessedType ) ;
354330 this . _metaData . size = data . length ;
355331 } else if ( data && data . base64 ) {
356- // 也可以是 dataURL,内部已做兼容
357- var dataBase64 = dataURItoBlob ( data . base64 , guessedType ) ;
332+ var parseBase64 = require ( './browserify-wrapper/parse-base64' ) ;
333+ var dataBase64 = parseBase64 ( data . base64 , guessedType ) ;
358334 this . _source = AV . Promise . as ( dataBase64 , guessedType ) ;
359335 } else if ( data && data . blob ) {
360336 this . _source = AV . Promise . as ( data . blob , guessedType ) ;
0 commit comments