Created
March 20, 2020 06:32
-
-
Save ccwq/de38a651cb36f2675b89b6a33d837e0a to your computer and use it in GitHub Desktop.
js 文件各种转换
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* blobURL2blob | |
* @param blobURL | |
* @returns {Promise<any>} | |
*/ | |
export function blobURL2blob(blobURL){ | |
return new Promise((resolve, reject) => { | |
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', blobURL, true); | |
xhr.responseType = 'blob'; | |
xhr.onload = function(e) { | |
if (this.status == 200) { | |
resolve(this.response); | |
// var myBlob = this.response; | |
// // myBlob is now the blob that the object URL pointed to. | |
}else{ | |
reject(this) | |
} | |
}; | |
xhr.onerror = reject; | |
xhr.send(); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment